﻿//not Popup 
//

//////////////////////////////////////////////////////////////////////
// AgentPanel.js

//////////////////////////////////////////////////////////////////////
// ステータス
//R[h
var REQUEST_400				="400";
var REQUEST_403				="403";
var REQUEST_404				="404";
var REQUEST_406				="406";
var REQUEST_486				="486";


//
// エージェント
var STATE_WAIT				=  0; // 待機中
var STATE_LOGOFF			=  1; // Logoff
var STATE_PREPARING			=  2; // 接続準備中(未使用)
var STATE_OFFERING			=  3; // オファリング中
var STATE_CONNECT			=  4; // 通話中
var STATE_WORKTIME			=  5; // ワークタイム中
var STATE_SEATOFF			=  6; // 離席中
var STATE_TELEPHONE			=  7; // 単独電話使用中
// 発信
var STATE_PREPARING			= 10; // 発信通話中(未使用)
var STATE_CALLING			= 11; // 相手端末呼出
var STATE_NMCALLING			= 12; // 自端末呼出
// 保留
var STATE_HOLDING			= 20; // 保留中
// 転送
var STATE_TRANSFERING		= 30; // 転送先との通話中
var STATE_SWITCHING			= 31; // 転送先と転送元の通話の切り替え中
var STATE_TRANOFFERING		= 32; // 転送元との通話中
var STATE_BRIND				= 33; // ブラインド転送中(未使用)
var STATE_CONSULTAION		= 34; // コンサルテーション転送中(未使用)
var STATE_TRANCALLING		= 35 ;
// 会議
var STATE_SETUP_CONF		= 40; // 会議リソースの生成
var STATE_CONFERENCEING		= 41; // 会議招集先の呼出との会話中
var STATE_CONFERENCE		= 42; // 会議会話中
var STATE_CONFLEAVECALLING	= 43; // 会議リソースの開放中(未使用)
var STATE_CONFLEAVESWITCHING= 44; // 会議の切り替え中(未使用)
var STATE_CONFOFFERING		= 45; // 会議元との通話中
// モニタ
var STATE_SETUP_MONI		= 50; // モニタリソースの生成
var STATE_MONITORING		= 51; // モニタ招集先の呼出との会話中
var STATE_MONITOR			= 52; // モニタ会話中
var STATE_MONIOFFERING		= 53; // モニタ元との通話中
// 通話録音
var STATE_RECORDING			= 60; // 通話録音中
// etc
var STATE_MAX 				= 61;
var STATE_DISABLE			= 100;
var playVoice=0;

//////////////////////////////////////////////////////////////////////
// コマンド番号

var CMD_DISABLE			=  0, CMD_LOGON			=  1, CMD_LOGOFF		=  2;
var CMD_BGN_WAIT		=  3, CMD_BGN_WORKTIME		=  4, CMD_BGN_SEATOFF		=  5;
var CMD_CONNECT			=  6, CMD_DISCONNECT		=  7, CMD_BGN_HOLD		=  8;
var CMD_END_HOLD		=  9, CMD_FORWARD_CNF		= 10, CMD_CANCEL_FORWARD	= 11;
var CMD_MESSAGE			= 12, CMD_GET_LIST		= 13, CMD_BGN_RECORD		= 14;
var CMD_END_RECORD		= 15, CMD_CONFERENCE		= 16, CMD_MONITOR		= 17;
var CMD_CANCEL_MEETING		= 18, CMD_MEETING_LEAVE		= 19, CMD_OFFHOOK		= 20;
var CMD_CONFERENCE_CNF		= 21, CMD_SETTING		= 22;
var CMD_RECORDLIST		= 23, CMD_CALLBACK		= 24;

//////////////////////////////////////////////////////////////////////
// ボタン番号(連番のみ)

var BTN_MAINSTATUS	= 0;
var BTN_WAIT		=  1, BTN_WORKTIME	=  2, BTN_SEATOFF		= 3;
var BTN_CONNECT		=  4, BTN_HOLD		=  5, BTN_TRANSFER		= 6;
var BTN_CONFERENCE	=  7, BTN_RECORD	=  8, BTN_DISCONNECT		= 9;
var BTN_MESSAGE		= 10, BTN_SETTING	= 11, BTN_LOGON			= 12;
var BTN_RECORDLIST	= 13, BTN_CALLBACK 	= 14;
var BTN_NUM 		= 15;

//////////////////////////////////////////////////////////////////////
// ボタン情報

// g_aButtonInfo[nButton][nInfo]
// nButton = ボタン番号
// 'n' はボタン状態番号を示す
// nInfo:0       = HTML ButtonID
// nInfo:1       = 現在のボタン状態番号(初期値:0)
// nInfo:100 + n = 表示文字
// nInfo:200 + n = 表示する CSS 名
// nInfo:300 + n = 押された時に実行するコマンド

// Alloc g_aButtonInfo
var g_aButtonInfo = new Array(BTN_NUM);
for(i = 0; i < BTN_NUM; i++) g_aButtonInfo[i] = new Array(336);

// BTN_MAINSTATUS
nButton = BTN_MAINSTATUS;
g_aButtonInfo[nButton][0]			= "btnMainStatus";
g_aButtonInfo[nButton][1]			= 0;
g_aButtonInfo[nButton][100 +  0]	= "";
g_aButtonInfo[nButton][200 +  0]	= "MainStatusDisable";
g_aButtonInfo[nButton][300 +  0]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  1]	= "AP0040002";
g_aButtonInfo[nButton][200 +  1]	= "MainStatusDisable";
g_aButtonInfo[nButton][300 +  1]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  2]	= "AP0040003";
g_aButtonInfo[nButton][200 +  2]	= "MainStatusAttention";
g_aButtonInfo[nButton][300 +  2]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  3]	= "AP0040004";
g_aButtonInfo[nButton][200 +  3]	= "MainStatusAgent";
g_aButtonInfo[nButton][300 +  3]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  4]	= "AP0040005";
g_aButtonInfo[nButton][200 +  4]	= "MainStatusDisable";
g_aButtonInfo[nButton][300 +  4]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  5]	= "AP0040006";
g_aButtonInfo[nButton][200 +  5]	= "MainStatusNotice";
g_aButtonInfo[nButton][300 +  5]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  6]	= "AP0040007";
g_aButtonInfo[nButton][200 +  6]	= "MainStatusPhone";
g_aButtonInfo[nButton][300 +  6]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  7]	= "AP0040008";
g_aButtonInfo[nButton][200 +  7]	= "MainStatusNotice";
g_aButtonInfo[nButton][300 +  7]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  8]	= "AP0040009";
g_aButtonInfo[nButton][200 +  8]	= "MainStatusNotice";
g_aButtonInfo[nButton][300 +  8]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  9]	= "AP0040010";
g_aButtonInfo[nButton][200 +  9]	= "MainStatusNotice";
g_aButtonInfo[nButton][300 +  9]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 + 10]	= "AP0040011";
g_aButtonInfo[nButton][200 + 10]	= "MainStatusPhone";
g_aButtonInfo[nButton][300 + 10]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 + 11]	= "AP0040012";
g_aButtonInfo[nButton][200 + 11]	= "MainStatusPhone";
g_aButtonInfo[nButton][300 + 11]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 + 12]	= "AP0040013";
g_aButtonInfo[nButton][200 + 12]	= "MainStatusNotice";
g_aButtonInfo[nButton][300 + 12]	= CMD_DISABLE;
// BTN_WAIT
nButton = BTN_WAIT;
g_aButtonInfo[nButton][0]			= "btnWait";
g_aButtonInfo[nButton][1]			= 0;
g_aButtonInfo[nButton][100 +  0]	= "AP0040014";
g_aButtonInfo[nButton][200 +  0]	= "PanelButtonDisable";
g_aButtonInfo[nButton][300 +  0]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  1]	= "AP0040014";
g_aButtonInfo[nButton][200 +  1]	= "PanelButtonAgent";
g_aButtonInfo[nButton][300 +  1]	= CMD_BGN_WAIT;
// BTN_WORKTIME
nButton = BTN_WORKTIME;
g_aButtonInfo[nButton][0]			= "btnWorktime";
g_aButtonInfo[nButton][1]			= 0;
g_aButtonInfo[nButton][100 +  0]	= "AP0040015";
g_aButtonInfo[nButton][200 +  0]	= "PanelButtonDisable";
g_aButtonInfo[nButton][300 +  0]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  1]	= "AP0040015";
g_aButtonInfo[nButton][200 +  1]	= "PanelButtonAgent";
g_aButtonInfo[nButton][300 +  1]	= CMD_BGN_WORKTIME;
// BTN_SEATOFF
nButton = BTN_SEATOFF;
g_aButtonInfo[nButton][0]			= "btnSeatoff";
g_aButtonInfo[nButton][1]			= 0;
g_aButtonInfo[nButton][100 +  0]	= "AP0040016";
g_aButtonInfo[nButton][200 +  0]	= "PanelButtonDisable";
g_aButtonInfo[nButton][300 +  0]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  1]	= "AP0040016";
g_aButtonInfo[nButton][200 +  1]	= "PanelButtonAgent";
g_aButtonInfo[nButton][300 +  1]	= CMD_BGN_SEATOFF;
// BTN_CONNECT
nButton = BTN_CONNECT;
g_aButtonInfo[nButton][0]			= "btnConnect";
g_aButtonInfo[nButton][1]			= 0;
g_aButtonInfo[nButton][100 +  0]	= "AP0040017";
g_aButtonInfo[nButton][200 +  0]	= "PanelButtonDisable";
g_aButtonInfo[nButton][300 +  0]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  1]	= "AP0040017";
g_aButtonInfo[nButton][200 +  1]	= "PanelButtonPhone";
g_aButtonInfo[nButton][300 +  1]	= CMD_CONNECT;
// BTN_HOLD
nButton = BTN_HOLD;
g_aButtonInfo[nButton][0]			= "btnHold";
g_aButtonInfo[nButton][1]			= 0;
g_aButtonInfo[nButton][100 +  0]	= "AP0040018";
g_aButtonInfo[nButton][200 +  0]	= "PanelButtonDisable";
g_aButtonInfo[nButton][300 +  0]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  1]	= "AP0040018";
g_aButtonInfo[nButton][200 +  1]	= "PanelButtonPhone";
g_aButtonInfo[nButton][300 +  1]	= CMD_BGN_HOLD;
g_aButtonInfo[nButton][100 +  2]	= "AP0040019";
g_aButtonInfo[nButton][200 +  2]	= "PanelButtonNotice";
g_aButtonInfo[nButton][300 +  2]	= CMD_END_HOLD;
// BTN_TRANSFER
nButton = BTN_TRANSFER;
g_aButtonInfo[nButton][0]			= "btnTransfer";
g_aButtonInfo[nButton][1]			= 0;
g_aButtonInfo[nButton][100 +  0]	= "AP0040020";
g_aButtonInfo[nButton][200 +  0]	= "PanelButtonDisable";
g_aButtonInfo[nButton][300 +  0]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  1]	= "AP0040020";
g_aButtonInfo[nButton][200 +  1]	= "PanelButtonPhone";
g_aButtonInfo[nButton][300 +  1]	= CMD_GET_LIST;
g_aButtonInfo[nButton][100 +  2]	= "AP0040021";
g_aButtonInfo[nButton][200 +  2]	= "PanelButtonNotice";
g_aButtonInfo[nButton][300 +  2]	= CMD_FORWARD_CNF;
// BTN_CONFERENCE
nButton = BTN_CONFERENCE;
g_aButtonInfo[nButton][0]			= "btnConference";
g_aButtonInfo[nButton][1]			= 0;
g_aButtonInfo[nButton][100 +  0]	= "AP0040022";
g_aButtonInfo[nButton][200 +  0]	= "PanelButtonDisable";
g_aButtonInfo[nButton][300 +  0]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  1]	= "AP0040023";
g_aButtonInfo[nButton][200 +  1]	= "PanelButtonPhone";
g_aButtonInfo[nButton][300 +  1]	= CMD_CONFERENCE;
g_aButtonInfo[nButton][100 +  2]	= "AP0040024";
g_aButtonInfo[nButton][200 +  2]	= "PanelButtonNotice";
g_aButtonInfo[nButton][300 +  2]	= CMD_CONFERENCE;
// BTN_RECORD
nButton = BTN_RECORD;
g_aButtonInfo[nButton][0]			= "btnRecord";
g_aButtonInfo[nButton][1]			= 0;
g_aButtonInfo[nButton][100 +  0]	= "AP0040025";
g_aButtonInfo[nButton][200 +  0]	= "PanelButtonDisable";
g_aButtonInfo[nButton][300 +  0]	= CMD_DISABLE;
//g_aButtonInfo[nButton][100 +  1]	= "AP0040025";
//g_aButtonInfo[nButton][200 +  1]	= "PanelButtonPhone";
//g_aButtonInfo[nButton][300 +  1]	= CMD_BGN_RECORD;
g_aButtonInfo[nButton][100 +  1]	= "AP0040026";
g_aButtonInfo[nButton][200 +  1]	= "PanelButtonNotice";
g_aButtonInfo[nButton][300 +  1]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  2]	= "AP0040027";
g_aButtonInfo[nButton][200 +  2]	= "PanelButtonNotice";
g_aButtonInfo[nButton][300 +  2]	= CMD_END_RECORD;
// BTN_DISCONNECT
nButton = BTN_DISCONNECT;
g_aButtonInfo[nButton][0]			= "btnDisconnect";
g_aButtonInfo[nButton][1]			= 0;
g_aButtonInfo[nButton][100 +  0]	= "AP0040028";
g_aButtonInfo[nButton][200 +  0]	= "PanelButtonDisable";
g_aButtonInfo[nButton][300 +  0]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  1]	= "AP0040028";
g_aButtonInfo[nButton][200 +  1]	= "PanelButtonAttention";
g_aButtonInfo[nButton][300 +  1]	= CMD_DISCONNECT;
g_aButtonInfo[nButton][100 +  2]	= "AP0040029";
g_aButtonInfo[nButton][200 +  2]	= "PanelButtonNotice";
g_aButtonInfo[nButton][300 +  2]	= CMD_CANCEL_FORWARD;
g_aButtonInfo[nButton][100 +  3]	= "AP0040030";
g_aButtonInfo[nButton][200 +  3]	= "PanelButtonNotice";
g_aButtonInfo[nButton][300 +  3]	= CMD_CANCEL_MEETING;
g_aButtonInfo[nButton][100 +  4]	= "AP0040030";
g_aButtonInfo[nButton][200 +  4]	= "PanelButtonNotice";
g_aButtonInfo[nButton][300 +  4]	= CMD_MEETING_LEAVE;
// BTN_MESSAGE
nButton = BTN_MESSAGE;
g_aButtonInfo[nButton][0]			= "btnMessage";
g_aButtonInfo[nButton][1]			= 0;
g_aButtonInfo[nButton][100 +  0]	= "AP0040031";
g_aButtonInfo[nButton][200 +  0]	= "PanelButtonDisable";
g_aButtonInfo[nButton][300 +  0]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  1]	= "AP0040031";
g_aButtonInfo[nButton][200 +  1]	= "PanelButtonAgent";
g_aButtonInfo[nButton][300 +  1]	= CMD_MESSAGE;

// BTN_SETTING
nButton = BTN_SETTING;
g_aButtonInfo[nButton][0]			= "btnSetting";
g_aButtonInfo[nButton][1]			= 0;
g_aButtonInfo[nButton][100 +  0]	= "AP0040032";
g_aButtonInfo[nButton][200 +  0]	= "PanelButtonDisable";
g_aButtonInfo[nButton][300 +  0]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  1]	= "AP0040032";
g_aButtonInfo[nButton][200 +  1]	= "PanelButtonAgent";
g_aButtonInfo[nButton][300 +  1]	= CMD_SETTING;

// BTN_LOGON

nButton = BTN_LOGON;
g_aButtonInfo[nButton][0]			= "btnLogon";
g_aButtonInfo[nButton][1]			= 0;
g_aButtonInfo[nButton][100 +  0]	= "AP0040033";
g_aButtonInfo[nButton][200 +  0]	= "PanelButtonDisable";
g_aButtonInfo[nButton][300 +  0]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  1]	= "AP0040034";
g_aButtonInfo[nButton][200 +  1]	= "PanelButtonAgent";
g_aButtonInfo[nButton][300 +  1]	= CMD_LOGON;
g_aButtonInfo[nButton][100 +  2]	= "AP0040033";
g_aButtonInfo[nButton][200 +  2]	= "PanelButtonAgent";
g_aButtonInfo[nButton][300 +  2]	= CMD_LOGOFF;

//BTN_RECORDLIST

nButton = BTN_RECORDLIST;
g_aButtonInfo[nButton][0]		= "btnRecordList";
g_aButtonInfo[nButton][1]		= 0;
g_aButtonInfo[nButton][100 +  0]	= "AP0040035";
g_aButtonInfo[nButton][200 +  0]	= "PanelButtonDisable";
g_aButtonInfo[nButton][300 +  0]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  1]	= "AP0040035";
g_aButtonInfo[nButton][200 +  1]	= "PanelButtonAgent";
g_aButtonInfo[nButton][300 +  1]	= CMD_RECORDLIST;

//BTN_CALLBACK

nButton = BTN_CALLBACK;
g_aButtonInfo[nButton][0]		= "btnCallBack";
g_aButtonInfo[nButton][1]		= 0;
g_aButtonInfo[nButton][100 +  0]	= "AP0040036";
g_aButtonInfo[nButton][200 +  0]	= "PanelButtonDisable";
g_aButtonInfo[nButton][300 +  0]	= CMD_DISABLE;
g_aButtonInfo[nButton][100 +  1]	= "AP0040036";
g_aButtonInfo[nButton][200 +  1]	= "PanelButtonAgent";
g_aButtonInfo[nButton][300 +  1]	= CMD_CALLBACK;

//////////////////////////////////////////////////////////////////////
// ステータス - ボタン状態 対応表

// 各ステータスにおけるボタン状態を指定する
// ボタンの並びはボタン番号順
// STATUS, WAIT, WORKTIME, SEATOFF, CONNECT, HOLD, TRANSFER, CONFERENCE, RECORD, DISCONNECT, MESSAGE, SETTING, LOGON
// ボタン状態の10番以降は大文字のA-Zで指定する

var g_aStatusButton = new Array(STATE_MAX);
//                                           SWWSCHTCRDMSL
g_aStatusButton[ STATE_DISABLE			] = "0000000000000"; // 切り替え中
g_aStatusButton[ STATE_WAIT			] = "2011100100002"; // 待機中
g_aStatusButton[ STATE_LOGOFF			] = "1000000000011"; // Logoff
g_aStatusButton[ STATE_PREPARING		] = "3000000000000"; // 接続準備中(未使用)
g_aStatusButton[ STATE_OFFERING			] = "5000011101100"; // オファリング中
g_aStatusButton[ STATE_CONNECT			] = "6000010111100"; // 通話中
g_aStatusButton[ STATE_WORKTIME			] = "3101100100102"; // ワークタイム中
g_aStatusButton[ STATE_SEATOFF			] = "4110100100102"; // 離席中
g_aStatusButton[ STATE_TELEPHONE		] = "6000011101100"; // 単独電話使用中
g_aStatusButton[ STATE_PREPARING		] = "6000011101100"; // 発信通話中(未使用)
g_aStatusButton[ STATE_CALLING			] = "6000011101100"; // 相手端末呼出
g_aStatusButton[ STATE_NMCALLING		] = "6000011101100"; // 自端末呼出
g_aStatusButton[ STATE_HOLDING			] = "7000121100100"; // 保留中
g_aStatusButton[ STATE_TRANSFERING		] = "8000012112100"; // 転送先との通話中
g_aStatusButton[ STATE_SWITCHING		] = "8000000001100"; // 転送先と転送元の通話の切り替え中
//g_aStatusButton[ STATE_TRANOFFERING		] = "8000011101100"; // 転送元との通話中
g_aStatusButton[ STATE_TRANOFFERING		] = "8000000001100"; // 転送元との通話中

g_aStatusButton[ STATE_TRANCALLING		] = "8000000002100"; // 転送先と呼び出し中

g_aStatusButton[ STATE_BRIND			] = "8000000000100"; // ブラインド転送中(未使用)
g_aStatusButton[ STATE_CONSULTAION		] = "8000000000100"; // コンサルテーション転送中(未使用)
g_aStatusButton[ STATE_SETUP_CONF		] = "9000000001100"; // 会議リソースの生成
g_aStatusButton[ STATE_CONFERENCEING	] = "9000011101100"; // 会議招集先の呼出との会話中
g_aStatusButton[ STATE_CONFERENCE		] = "A000011201100"; // 会議会話中
g_aStatusButton[ STATE_CONFLEAVECALLING	] = "9000000000100"; // 会議リソースの開放中(未使用)
g_aStatusButton[ STATE_CONFLEAVESWITCHING]= "9000000000100"; // 会議の切り替え中(未使用)
g_aStatusButton[ STATE_CONFOFFERING		] = "A000011101100"; // 会議元との通話中
g_aStatusButton[ STATE_SETUP_MONI		] = "B000000001100"; // モニタリソースの生成
g_aStatusButton[ STATE_MONITORING		] = "B000011101100"; // モニタ招集先の呼出との会話中
g_aStatusButton[ STATE_MONITOR			] = "B000011101100"; // モニタ会話中
g_aStatusButton[ STATE_MONIOFFERING		] = "B000011101100"; // モニタ元との通話中
g_aStatusButton[ STATE_RECORDING		] = "C000011121100"; // 通話録音中


//////////////////////////////////////////////////////////////////////
// SetPanelState

var PANELSTATE_HIDE			= 0;
var PANELSTATE_NORMAL		= 1;
var PANELSTATE_MINIMIZED	= 2;


//////////////////////////////////////////////////////////////////////
// SetPanelIcon

var PANELICON_NORMAL	= 0;
var PANELICON_NOTICE	= 1;
var PANELICON_ERROR		= 2;


//////////////////////////////////////////////////////////////////////
// ShowBalloonTip icon type

var TIPICON_NONE	= 0;
var TIPICON_INFO	= 1;
var TIPICON_WARNING	= 2;
var TIPICON_ERROR	= 3;


//////////////////////////////////////////////////////////////////////
// ShowMsgBox flags

// Buttons
var MSGBOXB_OK				= 0;
var MSGBOXB_OKCANCEL		= 1;
var MSGBOXB_ABORTRETRYIGNORE= 2;
var MSGBOXB_YESNOCANCEL		= 3;
var MSGBOXB_YESNO			= 4;
var MSGBOXB_RETRYCANCEL		= 5;
// Icon type
var MSGBOXI_NONE			= 0;
var MSGBOXI_ERROR			= 16;
var MSGBOXI_HAND			= 16;
var MSGBOXI_STOP			= 16;
var MSGBOXI_QUESTION		= 32;
var MSGBOXI_EXCLAMATION		= 48;
var MSGBOXI_WARNING			= 48;
var MSGBOXI_INFORMATION		= 64;
var MSGBOXI_ASTERISK		= 64;
// Result
var MSGBOXR_NONE			= 0;
var MSGBOXR_OK				= 1;
var MSGBOXR_CANCEL			= 2;
var MSGBOXR_ABORT			= 3;
var MSGBOXR_RETRY			= 4;
var MSGBOXR_IGNORE			= 5;
var MSGBOXR_YES				= 6;
var MSGBOXR_NO				= 7;


//////////////////////////////////////////////////////////////////////
// グローバル変数

var g_nAgentStatus = STATE_DISABLE;
var g_objListParams = CreateParams();
var g_nListCnt = 0;
var g_sAgentStatusId = "";
var g_iHelp = 0 ;
var g_iCallBack = 0 ;
var g_CallbackID=-1;
var g_PCallBack=null;
var g_PRecord=null;
var g_TenantID="";
var g_TenantPass="";
var g_ServerURL="";
var g_ServerPort="";
var g_ServerName="";

// 追加　寺尾
var g_vCallerID = "" ;
var g_CustomerName = "" ;
var g_OfferingWindow = 0 ;
var g_vSkillGrp = "" ;
var g_vGrp = "" ;
var g_ReRoute=0;
//add,xzg,2009/06/09,S---------
var g_objGroupList = CreateParams();
//add,xzg,2009/06/09,E---------
var g_iTimeOut=0;
var g_iLogOff=0;
var g_WaitTime=0;
var g_isSetWatiTime=0;

//add,xzg,2009/06/18,S---------
var g_iKeepAlive=60000;
//add,xzg,2009/06/18,E---------
//add,xzg,2009/09/07,S----
var g_vURL="";
var g_objOffParams = CreateParams();
//add,xzg,2009/09/07,E----

//add,xzg,2009/12/01,S--------
var g_clickWork=0;
//add,xzg,2009/12/01,E--------
//add,xzg,2009/12/28,S-------
var g_objAgentList = CreateParams();
//add,xzg,2009/12/28,E-------

//add,xzg,2010/01/12,S----------
var g_getAgentList=0;
var g_cmdGetList=0;
//add,xzg,2010/01/12,E----------

//add,xzg,acx,S---------
var g_PreAgentStatus=-1;
var g_PreCallStatus=-1;
//add,xzg,acx,E---------

//add,xzg,acx,2010/02/02,S---------
var g_ResultCode=1;
var g_CallDateS="";
var g_CallDateE="";
var g_CallType="-1";
var g_TelNo="";
var g_EventID="0";
var g_ResultCodeEx=0;
//add,xzg,acx,2010/02/02,E---------
//add,xzg,acx,2010/02/09,S---------
var g_HasConneted=0;
var g_TransConnected="-1";
//add,xzg,acx,2010/02/09,E---------
//add,xzg,acx,2010/02/10,S---------
var g_AcxOnConnect=0;
//add,xzg,acx,2010/02/10,E---------
//add,xzg,acx,2010/02/17,S---------
var g_AcxAgentTrans=0;
//add,xzg,acx,2010/02/17,E---------

//add,xzg,2010/03/02,S---------
var g_RebootAgentStatus = STATE_LOGOFF;
//add,xzg,2010/03/02,E---------


//xzg,SFA,S
var AfterLoginMode=-1;
var g_POption=null;
var g_vTel="";
var iNumberOfVmail=0;
var iNumberOfQueCall=0;
var g_MakeCall=null
var g_MakeCallID=-1
var g_iMakeCall=0

var g_PChat=null;
var g_ClientName="";
var g_ClientVer=2.0;
var myKeepAliveTime=0;
//xzg,SFA,E
//add,xzg,2010/11/19,S
var g_AcxConnected=0;  //connected count
//add,xzg,2010/11/19,E
//////////////////////////////////////////////////////////////////////
function document_onmouseout()
{
	
	if (event.clientX ==-1)
	{
		window.external.hideMe();
	}
}
function document_onmouseover()
{	
	window.external.showMe();	
}
/*
function checkNum(){
	if (telNo.value.match("/[^0-9]+/")){
		alert( "1");
	}
	else
	{
		alert( "0");
	}
}
*/
function checkdig(inValue){
	if (inValue.match("/[^0-9]+/")){
		return true;
	}
	else
	{
		return false;
	}
}
function checkNum(iKey){
//update,xzg,2009/08/20,S--------
	//if (iKey==13 || iKey==40 || iKey==46){
	if (iKey==13 || iKey==40){
//update,xzg,2009/08/20,E--------
		//add,xzg,2009/12/11,S----
		if (iKey==13 && telNo.value.length>0)
		{
			if (g_nAgentStatus==STATE_WAIT || g_nAgentStatus==STATE_SEATOFF
				|| g_nAgentStatus==STATE_WORKTIME
				|| g_nAgentStatus==STATE_HOLDING
			    )
			{
				CmdConnect();			
			}
			return;
		}
		//add,xzg,2009/12/11,S----
		//callerList.width="0";		
		callerList.style.visibility="";
		callerList.focus();
		return
	}
	if (iKey==38){		
		callerList.style.visibility="hidden";
		telNo.focus();
		return
	}
	//if (iKey!=8 && iKey!=220 && (iKey<48 || iKey>105 || (iKey<96 && iKey>57)) && iKey<35 && iKey>40){
/*del,xzg,2009/08/20,S
	if (iKey>=65 && iKey<=90 || iKey>105 ){
		event.returnValue=false;
	}
*/	
	
}
function unShow(){
	callerList.style.visibility="hidden";
	telNo.focus();
}
//add,xzg,2009/06/25,S----
var tt=1;
function selectCaller1(){
	tt   =   tt?0:1;   
	if(!tt) return;
	telNo.value=callerList.value;
	callerList.style.visibility="hidden";
	telNo.focus();
	return;	
}
//add,xzg,2009/06/25,E----
function selectCaller(iKey){	
	if(iKey==27){
		callerList.style.visibility="hidden";
		telNo.focus();

	}
	if (iKey==13){
		telNo.value=callerList.value;
		callerList.style.visibility="hidden";
		telNo.focus();
		return
	}
}
function onShowMsg(){
	//objtabmsgD=document.getElementById("tabmsgD");
	//objtabmsgD.style.visiblity="hidden";
	window.external.SetPanelSize(document.body.scrollWidth+6, document.body.scrollHeight);
}

function onUnShowMsg(){
	//objtabmsgD=document.getElementById("tabmsgD");
	//objtabmsgD.style.visiblity="visible";
	window.external.SetPanelSize(document.body.scrollWidth+6, document.body.scrollHeight-115);
}

// OnBodyLoad

function OnBodyLoad()
{
	// 最初は最小化されているので、ノーマル表示にします。
//update,xzg,2010/02/10,S----------
//window.external.SetPanelState(PANELSTATE_NORMAL);
if (window.external.GetPanelMin()==1) window.external.SetPanelState(PANELSTATE_NORMAL);
else
{ 
	window.external.SetPanelState(PANELSTATE_NORMAL);
	window.external.SetPanelState(PANELSTATE_HIDE);
}
//update,xzg,2010/02/10,E----------
//add,xzg,SFA,S
window.external.SetPanelState(PANELSTATE_HIDE);
//add,xzg,SFA,E
	// パネルのサイズを設定します。パネルの位置はフォーム側で設定されます。
	window.external.SetPanelSize(document.body.scrollWidth+6, document.body.scrollHeight-115);
	// パネルのタイトルを設定します。
	window.external.SetPanelTitle("AP0040001");

	window.external.SetPanelIcon(PANELICON_ERROR);
	// パネルのエージェント情報を設定します。
	objProfile = window.external.Profile;
	objProfile.SelectSection("AgentPanel");
	p_sSoftPhone=objProfile.GetStringDefault("sSoftPhoe", "");

	// SetAgentStatus
	g_iHelp=2;
	SetAgentStatus(STATE_LOGOFF);
	btnShowMsg.innerText="▼";
	btnUnShowMsg.innerText="▲";
	telNo.focus();
	//add,xzg,2009/12/21 AcxOpen
	window.external.AcxOpen(18230);
}

function OnBodyUnload()
{
	// CpfMsgClose
	window.external.CpfMsgClose();
	// パネルの位置はフォーム側が保存します。
	//add,xzg,2009/12/21
	window.external.CpfMsgClose();
}


//////////////////////////////////////////////////////////////////////
// Tools

function ShowMsgBox(text, caption, buttons, icon)
{
	return window.external.ShowMsgBox(text, caption, buttons, icon);
}

// CpfParams オブジェクトを作成します。
function CreateParams()
{
	return window.external.CreateCpfParams();
}

// イベントを送信します。
function SendEvent(sEvent, objParams)
{
	try
	{
		window.external.CpfMsgSendEvent(sEvent, objParams.GetParams());
	}
	catch(e)
	{
		alert("CpfMsgSendEvent() failed: " + e.description);
	}
}

// フォーム終了時は来ないので注意。
function OnCpfMsgClose()
{
	// SetPanelTitle
	//window.external.SetPanelTitle("エージェントパネル - ログオフ");
	//window.external.SetPanelTitle("エージェントパネル");
	window.external.SetPanelTitle("AP0040001");
	window.external.SetPanelIcon(PANELICON_ERROR);
	// SetAgentStatus
//add,xzg,2009/10/22,S----
window.clearInterval(myKeepAliveTime);
//add,xzg,2009/10/22,E----
	SetAgentStatus(STATE_LOGOFF);
//add,xzg,2009/05/18,S------
	if (g_iLogOff==2)
	{
		
		//add,xzg,Acx,S-----
		//add,xzg,2010/02/10,S-----
		if (g_AcxOnConnect==1 && window.external.GetPanelState==0)
		//add,xzg,2010/02/10,E-----
		Acx_OnServiceStopped(1);
		else
		{
			//add,xzg,SFA,S
			if (g_ClientName=="SFA" ) Acx_OnServiceStopped(1);
			//add,xzg,SFA,E
		//add,xzg,Acx,E-----

		//update,xzg,SFA
		//再起動してください。->再ログインまたは再起動してください。
		if (hLanguage.value="JP")
			alert("ネットワークが切断されました。\nネットワークの確認の上、再ログインまたは再起動してください。");
		else
			alert("Network disconnected. \nAfter check the network, please restart the application.");
		}

	}
	g_iLogOff=0;
	//add,xzg,2009/05/18,E------
}

//add,xzg,2009/05/15,S----
function autoWait()
{
	window.clearInterval(myTime);
//add,xzg,2009/12/01,S---
	if (g_clickWork==1)
	{
		g_clickWork=0;
		g_isSetWatiTime=0;
		return;
	}
	g_clickWork=0;
//add,xzg,2009/12/01,E---

	btnWait.click();
	g_isSetWatiTime=0;
}
//add,xzg,2009/05/15,E----

//////////////////////////////////////////////////////////////////////
// 状態設定

function SetAgentStatus(nStatus)
{
	// Save
	g_nAgentStatus = nStatus;
	// Set ButtonState
	sButtonState = g_aStatusButton[g_nAgentStatus];
	//add,xzg,2009/05/15,S----
	if (STATE_WORKTIME==nStatus)
	{

		var time=0;
		time=g_WaitTime*1000;

		if (time>0 && 1!=g_isSetWatiTime)
		{
			g_isSetWatiTime=1;
		 	myTime=window.setInterval("autoWait()",time);

		}
	}
	else 
	{
		if (1==g_isSetWatiTime)
		{
			g_isSetWatiTime=0;
			window.clearInterval(myTime);

		}
	}
	//add,xzg,2009/05/15,E----

	if(sButtonState == undefined) return;
	for(i = 0; i < sButtonState.length; i++)
	{
		// Get ButtonElement
		objButton = document.getElementById(g_aButtonInfo[i][0]);
		if(objButton == null) continue;
		// Set ButtonState
		nState = 0;
		ch = sButtonState.charCodeAt(i);
		if((0x30 <= ch) && (ch <= 0x39)) nState = ch - 0x30;
		else if((0x41 <= ch) && (ch <= 0x5a)) nState = ch - 0x41 + 10;
		else continue;
		text = g_aButtonInfo[i][100 + nState];
		
		if ( i == BTN_CONFERENCE )
		{
			//alert(g_iHelp);
			if ( g_iHelp ==  0 )
			{
				text = "AP0040023";
				nState	=	1 ;
			}
			else if( g_iHelp ==  1 )
			{
				text = "AP0040024";
				nState	=	2 ;
			}
			else if( g_iHelp ==  2 )
			{
				text = "AP0040022";
				nState	=	0 ;
			}
		}
		else if(i == BTN_HOLD )
		{
			if (STATE_NMCALLING==nStatus || STATE_TRANSFERING==nStatus || STATE_CALLING==nStatus)
			{
				nState	=	0 ;
			}			

		}
		else if(i == BTN_TRANSFER )
		{
			if (STATE_NMCALLING==nStatus || STATE_CALLING==nStatus)
			{
				nState	=	0 ;
			}

		}
		sClassName = g_aButtonInfo[i][200 + nState];
		if(sClassName == undefined) continue;
		g_aButtonInfo[i][1] = nState;
		objButton.innerText = window.external.GetLangText(text);
		objButton.className = sClassName;
		//add,xzg,S--
		if (i==BTN_MESSAGE)
		{
			btnRecordList.innerText=window.external.GetLangText("AP0040035");
			btnCallBack.innerText=window.external.GetLangText("AP0040036");
			btnRecordList.className = sClassName;
			btnCallBack.className = sClassName;
			g_aButtonInfo[13][1] = nState;
			g_aButtonInfo[14][1] = nState;
		}
		//add,xzg,E--
	}	
}

//////////////////////////////////////////////////////////////////////
// ボタンコマンド

function OnPanelButton(nButton)
{
	// ボタン状態チェック
	//del,xzg,2010/01/20,S----
	//Msg.innerText=" ";
	//InfoMsg.innerText=" ";
	//del,xzg,2010/01/20,E----
	nState = g_aButtonInfo[nButton][1];
	if((nState == undefined) || (nState == 0)) return;
	//add,xzg,2009/12/01,S---
	g_clickWork=0
	//add,xzg,2009/12/01,E---
	// コマンド実行
	nCommand = g_aButtonInfo[nButton][300 + nState];
	try
	{
		switch(nCommand)
		{
		case CMD_DISABLE		: break;
		case CMD_SETTING		: CmdSetting(); break;
		case CMD_LOGON			: CmdLogon(); break;
		case CMD_LOGOFF			: CmdLogoff(); break;
		case CMD_BGN_WAIT		: CmdBgnWait(); break;
		case CMD_BGN_SEATOFF	: CmdBgnSeatoff(); break;
		//updat,xzg,2009/12/01,S---
		//case CMD_BGN_WORKTIME	: CmdBgnWorktime(); break;
		case CMD_BGN_WORKTIME	: g_clickWork=1;CmdBgnWorktime(); break;
		//updat,xzg,2009/12/01,E---
		case CMD_CONNECT		: CmdConnect(); break;
		case CMD_DISCONNECT		: CmdDisconnect(); break;
		case CMD_BGN_HOLD		: CmdBgnHold(); break;
		case CMD_END_HOLD		: CmdEndHold(); break;
		//update,xzg,2010/01/13,S--------
		case CMD_GET_LIST		: g_cmdGetList=1;CmdGetList(); break;
		//update,xzg,2010/01/13,E--------
		case CMD_FORWARD_CNF	: CmdForwardCnf(); break;
		case CMD_CANCEL_FORWARD	: CmdCancelForward(); break;
		case CMD_MESSAGE		: CmdMessage(); break;
		case CMD_BGN_RECORD		: CmdBgnRecord(); break;
		case CMD_END_RECORD		: CmdEndRecord(); break;
		case CMD_CONFERENCE		: CmdConference(); break;
		case CMD_CONFERENCE_CNF	: CmdConferenceCnf(); break;
		case CMD_MONITOR		: CmdMonitor(); break;
		case CMD_CANCEL_MEETING	: CmdCancelMeeting(); break;
		case CMD_MEETING_LEAVE	: CmdMeetingLeave(); break;
		case CMD_OFFHOOK		: CmdOffhook(); break;
		case CMD_RECORDLIST		: CmdRecordList(); break;
		case CMD_CALLBACK		: CmdCallBack(); break;
		default:
			throw new Error("Invalid Command ID");
			break;
		}
	}
	catch(e)
	{
		alert("OnPanelButton/Error: " + e.description);
	}
}


//////////////////////////////////////////////////////////////////////
// コマンド受信

function OnCpfMsgCommand(sCommand, sParams)
{
	// alert("[" + sCommand + "]\r\n" + sParams);
	objSmParams = CreateParams();
	objSmParams.SetParams(sParams);
	// コマンド実行
	//add,xzg,2010/01/12,S-------------
	//g_getAgentList=0;
	//add,xzg,2010/01/12,E-------------
	try
	{
		switch(sCommand)
		{
		case "SM_LOGON_CNF"			: SmLogonCnf(objSmParams); break;
		case "SM_LOGON_ERR"			: SmLogonErr(objSmParams); break;
		case "SM_LOGOFF_CNF"		: SmLogoffCnf(objSmParams); break;
		case "SM_LOGOFF"			: SmLogoff(objSmParams); break;
		case "SM_SEND_CNF"			: SmSendCnf(objSmParams); break;
		case "SM_ACTIVITY"			: SmActivity(objSmParams); break;
		case "SM_MESSAGE_IND"		: SmMessageInd(objSmParams); break;
		case "SM_STATUS"			: SmStatus(objSmParams); break;
		case "SM_CONNECT_CNF"		: SmConnectCnf(objSmParams); break;
		case "SM_DISCONNECT_CNF"	: SmDisconnectCnf(objSmParams); break;
		case "SM_OFFERING_IND"		: SmOfferingInd(objSmParams); break;
		case "SM_AGENT_LIST_RESULT"	: SmAgentListResult(objSmParams); break;
		case "SM_GET_LIST_RESULT"	: SmGetListResult(objSmParams); break;
		case "SM_FORWARD_ACK"		: SmForwardAck(objSmParams); break;
		case "SM_FORWARD_NAK"		: SmForwardNak(objSmParams); break;
		case "SM_FORWARD_IND"		: SmForwardInd(objSmParams); break;
		case "SM_FORWARD_ERR"		: SmForwardErr(objSmParams); break;
		case "SM_PLAY_LIST_RESULT"	: SmPlayListResult(objSmParams); break;
		case "SM_MONITORING_ACK"	: SmMonitoringAck(objSmParams); break;
		case "SM_MONITORING_NAK"	: SmMonitoringNak(objSmParams); break;
		case "SM_MEETING_ACK"		: SmMeetingAck(objSmParams); break;
		case "SM_MEETING_NAK"		: SmMeetingNak(objSmParams); break;
		case "SM_END_RECORDING"		: SmEndRecording(objSmParams); break;
		case "REBOOTED"		: SmRebooted(objSmParams); break;
		case "SM_GET_CUST_INFO_RESULT"	: break;
		case "REROUTE"	:  SmReroute(objSmParams);break;
//add,xzg,2009/06/09,S---------
		case "SM_GET_SKILLGROUP"	:  SmGetSkillGroup(objSmParams);break;
//add,xzg,2009/06/09,E---------
//add,xzg,2009/10/19,S--------
		case "SM_KEEPALIVE"		:  SmKeepAlive(objSmParams);break;
//add,xzg,2009/10/19,E--------
		default:
			throw new Error("Invalid Command: "  + sCommand);
			break;
		}
	}
	catch(e)
	{
		alert("OnCpfMsgCommand/Error: " + sCommand + e.description);
	}
}


//////////////////////////////////////////////////////////////////////
// Setting

function CmdSetting()
{
	// ShowDialog agentpanel_setting
	sRet = window.external.ShowModalDialog(
				"agentpanel_setting.asp?ln=" + hLanguage.value, window.external.Profile,
				"dialogWidth:250px;dialogHeight:200px;center:yes;status:no");
	if(sRet != "ok") return;
	
	// パネルのエージェント情報を設定します。
	objProfile = window.external.Profile;
	objProfile.SelectSection("AgentPanel");
	//p_sPhoneNo.value = objProfile.GetStringDefault("sPhoneNo", "");
	//update,xzg,2008/05/19,S-----
	//p_sDisplayName.value = objProfile.GetStringDefault("sDisplayName", "");]
	p_sSoftPhone=objProfile.GetStringDefault("sSoftPhoe", "");
	//update,xzg,2008/05/19,E-----
}

//////////////////////////////////////////////////////////////////////
// Logon

function CmdLogon()
{
	try
	{
		//add,xzg,2009/06/09,S---------
		g_objListParams.Clear();
		g_objGroupList.Clear();
		//add,xzg,2009/06/09,E--------
		// Get CpfMsgOpen Info
		objProfile = window.external.Profile;
		objProfile.SelectSection("AgentPanel");
		sPhoneNo = objProfile.GetStringDefault("sPhoneNo", "");
		if(sPhoneNo == "")
		{
			//ShowMsgBox("初期設定をして下さい。", "Logon", MSGBOXB_OK, MSGBOXI_ERROR);
			ShowMsgBox("AP9990003", "AP9990004", MSGBOXB_OK, MSGBOXI_ERROR);
			return;
		}
		sIpAddr = window.external.GetLocalAddr();
		//update,xzg,2008/10/28,S---
		//sName  = sPhoneNo;
		sAgentId = objProfile.GetStringDefault("sAgentId","");
		if (sAgentId.length<1)
		{
			//ShowMsgBox("エージェントを設定してください。", "Logon", MSGBOXB_OK, MSGBOXI_ERROR);
			ShowMsgBox("AP9990005", "AP9990004", MSGBOXB_OK, MSGBOXI_ERROR);
			return;
		}
		//sName=sAgentId + "_" + sPhoneNo;
		sName=hTenantID.value + "_" + sAgentId;
		//update,xzg,2008/10/28,E---
		//add,xzg,2009/05/15,S---
		var waitTime=objProfile.GetStringDefault("sWaitTime", "0");
		if (waitTime=="") g_WaitTime=0;
		else g_WaitTime=parseInt(waitTime,10);
		//add,xzg,2009/05/15,E---
		sLogin = sPhoneNo;
		// CpfMsgOpen
		// この関数は直ぐに戻り、結果は OnCpfMsgOpen イベントで通知されます
		// Cpfmsgsvrアドレスを指定しなければ、CpfNameSvr に問い合わせます
		//window.external.CpfMsgOpen("", 0, "Server", "CONTROLPANEL", sName, "HA", "MAIN", sLogin);
		//window.external.CpfMsgOpen("122.103.239.43", 8208 , "Server", "CONTROLPANEL", sName, "HA", "MAIN", sLogin);
		controlpanel=hTenantID.value;
		url=hServerUrl.value;
		port=hServerPort.value;
		server=hServerName.value;
	//add,xzg,2009/12/28,S-------------
	groupSend.options.length=0;
	//add,xzg,2009/12/28,E-------------
		window.external.CpfMsgOpen(url, port , server, controlpanel, sName, "HA", "MAIN", sLogin);
		// SetAgentStatus
		SetAgentStatus(STATE_DISABLE);
		g_iHelp=0;
	}
	catch(e)
	{
		//ShowMsgBox("サーバとの接続に失敗しました。: " + e.description, "Logon", MSGBOXB_OK, MSGBOXI_ERROR);
		ShowMsgBox("AP9990006" , "AP9990004", MSGBOXB_OK, MSGBOXI_ERROR);

	}
}

function OnCpfMsgOpen(bResult, sInfo)
{
	// Check CpfMsgOpen() Result
	if(!bResult)
	{
		//ShowMsgBox("サーバとの接続に失敗しました。: " + sInfo, "Logon", MSGBOXB_OK, MSGBOXI_ERROR);
		ShowMsgBox("AP9990006" , "AP9990004", MSGBOXB_OK, MSGBOXI_ERROR);
		// SetAgentStatus
		SetAgentStatus(STATE_LOGOFF);
		return;
	}
	
	// Get Logon Info
	objProfile = window.external.Profile;
	objProfile.SelectSection("AgentPanel");
	sAgentId = objProfile.GetString("sAgentId");
//update,xzg,2008/05/19,S---
//login　グループと名前
//update,xzg,2008/05/19,E---
//	sDisplayName = objProfile.GetString("sDisplayName");
//	sGroupId = objProfile.GetString("sGroupId");
	sPhoneNo = objProfile.GetString("sPhoneNo");
//xzg,2009/02/03,S-----
	sIpAddr = window.external.GetLocalAddr();
//	sIpAddr = "AgentPanel";
//xzg,2009/02/03,E-----
	// UM_LOGON
	objUmParams = CreateParams();
	objUmParams.SetString("vStationAddr", sPhoneNo);
	objUmParams.SetString("iAgentID", sAgentId);
//	objUmParams.SetString("vDisplayName", sDisplayName);
//	objUmParams.SetString("vAgentTag", sGroupId);
//	objUmParams.SetString("iGroupID", sGroupId);
	objUmParams.SetString("vInfo", sIpAddr);
	var sPassword=objProfile.GetString("sPass");
	objUmParams.SetString("vPassword", sPassword);
	
	if (p_sSoftPhone=="Yes"){
		objUmParams.SetString("iConnType", 1);
	}
	else
	{
		objUmParams.SetString("iConnType", 0);
	}

	//add,xzg,2008/05/19,E----
	SendEvent("UM_LOGON", objUmParams);


}
//add,xzg,2009/06/09,S---------
function SmGetSkillGroup(objSmParams)
{
	sID=objSmParams.GetStringDefault("iSkillID","");
	sName=objSmParams.GetStringDefault("vSkillName","");
	listCount=g_objGroupList.Count();
	listCount=listCount/2+1;
	g_objGroupList.SetString("ID" + String(listCount), sID);
	g_objGroupList.SetString("Disp" + String(listCount), sName);
}
//add,xzg,2009/06/09,E---------

//add,xzg,2009/10/19,S--------
function SmKeepAlive(objSmParams)
{
iNumberOfVmail=objSmParams.GetStringDefault("iNumberOfVmail","0");

	if (iNumberOfVmail>0)
		btnVoiceMail.className="PanelButtonMail1";
	else
		btnVoiceMail.className="PanelButtonMail0";
	
	iNumberOfQueCall=objSmParams.GetStringDefault("iNumberOfQueCall","0");
	if (iNumberOfQueCall>3)
		btnQueCall.className="PanelButtonQue2";
	else if (iNumberOfQueCall>0)
		btnQueCall.className="PanelButtonQue1";
	else
		btnQueCall.className="PanelButtonQue0";

//add,xzg,SFA,S
Acx_OnChangeQueVoice(iNumberOfVmail,iNumberOfQueCall);
//add,xzg,SFA,E
return;

	iNumberOfVmail=objSmParams.GetStringDefault("iNumberOfVmail","0");
	iNumberOfQueCall=objSmParams.GetStringDefault("iNumberOfQueCall","0");
	if (g_nAgentStatus==STATE_WORKTIME)
	{
		var objButton;
		var vMsg="";
		if (iNumberOfVmail>0)
		{
			objButton= document.getElementById(g_aButtonInfo[BTN_CALLBACK][0]);
			objButton.className=g_aButtonInfo[BTN_CALLBACK][202];			

			if (Msg.innerText==" ")
			{
				vMsg=window.external.GetLangText("AP0040042");
				vMsg=vMsg + iNumberOfVmail;
				vMsg=vMsg + window.external.GetLangText("AP0040043");
				Msg.innerText=vMsg;
			}

		}
		if (iNumberOfQueCall>0)
		{
			objButton= document.getElementById(g_aButtonInfo[BTN_WAIT][0]);
			objButton.className=g_aButtonInfo[BTN_WAIT][202];			
			if (InfoMsg.innerText==" ")
			{
				vMsg=window.external.GetLangText("AP0040044");
				vMsg=vMsg + iNumberOfQueCall;
				vMsg=vMsg + window.external.GetLangText("AP0040045");
				InfoMsg.innerText=vMsg;
			}

		}
	}
}
//add,xzg,2009/10/19,E--------

//add,xzg,2009/06/18,S---------
function keepAlive()
{
	try
	{
	objUmParams = CreateParams();
	objUmParams.SetString("vKeepAlive", "1");
	SendEvent("UM_KEEPALIVE", objUmParams);
	}
	catch(e)
	{

	}
}

//add,xzg,2009/06/18,E---------

function SmLogonCnf(objSmParams)
{
	
	window.external.SetPanelIcon(PANELICON_NORMAL);
//add,xzg,2008/05/19,S----
	//p_sDisplayName.value=objSmParams.GetStringDefault("vDisplayName","");
//add,xzg,2008/05/19,E----

	// SetPanelTitle
	displayName=objSmParams.GetStringDefault("vDisplayName","");
	sPhone=objProfile.GetStringDefault("sPhoneNo", "");
	title=""
	if  (displayName=="" ) title=sPhone;
	else title=displayName + "("  + sPhone +")";
	//window.external.SetPanelTitle("エージェントパネル - " + title);
	window.external.SetPanelTitle("AP0040001" );

//add,xzg,2009/06/18,S---------
myKeepAliveTime=window.setInterval("keepAlive()",g_iKeepAlive);
//add,xzg,2009/06/18,E---------

//add,xzg,2008/10/23,S----
	//grouplist
	nCount = objSmParams.GetInt("Count");
	//add,xzg,2010/02/02,S--------
	objAcxGroupParams=CreateParams();
	objAcxGroupParams.SetString("gCount",objSmParams.GetStringDefault("Count","0"));
	//add,xzg,2010/02/02,E--------
	nAdd=0;
	for(i = 1; i <= nCount; i++)
	{
		sID = objSmParams.GetStringDefault("ID" + String(i),"");
		sDisp = objSmParams.GetString("Disp" + String(i));
		//add,xzg,2010/02/02,S--------
		objAcxGroupParams.SetString("gID" +String(i),sID);
		objAcxGroupParams.SetString("gDisp" +String(i),sDisp);
		//add,xzg,2010/02/02,E--------
		if (sID!="")
		{
			var oOption=new Option(sDisp,sID);
			nAdd=i;
			groupSend.options.add(oOption);
		}
	}
		//var oOption=new Option("4","test");
		//groupSend.options.add(oOption);

	//if (nAdd>0) groupSend.options.remove(0);
	

//add,xzg,2008/10/23,E----
	//add,xzg,2009/05/18,S----
	g_iLogOff=2;
	//add,xzg,2009/05/18,E----

	// SetAgentStatus
	SetAgentStatus(STATE_WORKTIME);
	//add,xzg,2010/03/02,S----------
	if (STATE_WAIT==g_RebootAgentStatus)

	{
		CmdBgnWait();
		g_RebootAgentStatus=STATE_LOGOFF;
	}
	else if (STATE_WORKTIME==g_RebootAgentStatus)
	{
		g_clickWork=1;
		CmdBgnWorktime();
		g_RebootAgentStatus=STATE_LOGOFF;
	}
	else if (STATE_SEATOFF==g_RebootAgentStatus)
	{
		CmdBgnSeatoff();
		g_RebootAgentStatus=STATE_LOGOFF;
	}
	//add,xzg,2010/03/02,E----------
}

function SmLogonErr(objSmParams)
{
	// CpfMsgClose
	window.external.CpfMsgClose();
	// ShowMsgBox

	//update,xzg,2009/02/12,S-------
	var vReason=objSmParams.GetString("vReason");
	var vErrMsg="";
	if ("__NONE__"==vReason)
	{
		//add,xzg,2010/02/05,S---
		g_ResultCodeEx=1001;
		//add,xzg,2010/02/05,E---
		//add,xzg,2010/02/17,S---
		if(g_AcxOnConnect!=1)
		//add,xzg,2010/02/17,E---
		ShowMsgBox("AP9990008","AP9990004", MSGBOXB_OK, MSGBOXI_ERROR);
	}
	else if ("__EXPIRE__"==vReason)
	{
		//add,xzg,2010/02/05,S---
		g_ResultCodeEx=1002;
		//add,xzg,2010/02/05,E---
		//add,xzg,2010/02/17,S---
		if(g_AcxOnConnect!=1)
		{
		//add,xzg,2010/02/17,E---
		ShowMsgBox("AP9990009","AP9990004", MSGBOXB_OK, MSGBOXI_ERROR);
		window.external.ShowPwdSet();
		}

	}
	else if ("__DISABLE__"==vReason)
	{
		//add,xzg,2010/02/05,S---
		g_ResultCodeEx=1003;
		//add,xzg,2010/02/05,E---
		//add,xzg,2010/02/17,S---
		if(g_AcxOnConnect!=1)
		//add,xzg,2010/02/17,E---
		ShowMsgBox("AP9990010","AP9990004", MSGBOXB_OK, MSGBOXI_ERROR);
	}
	else if ("__SAME__"==vReason)
	{
		//add,xzg,2010/02/05,S---
		g_ResultCodeEx=1004;
		//add,xzg,2010/02/05,E---
		//add,xzg,2010/02/17,S---
		if(g_AcxOnConnect!=1)
		{
		//add,xzg,2010/02/17,E---
		ShowMsgBox("AP9990011","AP9990004", MSGBOXB_OK, MSGBOXI_ERROR);
		window.external.ShowPwdSet();
		}
	
	}
	else if ("__AGENT__"==vReason)
	{
		//add,xzg,2010/02/05,S---
		g_ResultCodeEx=1005;
		//add,xzg,2010/02/05,E---
		//add,xzg,,SFA,2010/09/15,S
		if(g_AcxOnConnect!=1)
		//add,xzg,,SFA,2010/09/15,E
		ShowMsgBox("AP9990012","AP9990004", MSGBOXB_OK, MSGBOXI_ERROR);
	}
	else if ("__STATION__"==vReason)
	{
		//add,xzg,2010/02/05,S---
		g_ResultCodeEx=1006;
		//add,xzg,2010/02/05,E---
		//add,xzg,2010/02/17,S---
		if(g_AcxOnConnect!=1)
		//add,xzg,2010/02/17,E---
		ShowMsgBox("AP9990013","AP9990004", MSGBOXB_OK, MSGBOXI_ERROR);
	}
	else if ("EXPIRED"==vReason)
	{
		//add,xzg,2010/02/05,S---
		g_ResultCodeEx=1007;
		//add,xzg,2010/02/05,E---
		//add,xzg,2010/02/17,S---
		if(g_AcxOnConnect!=1)
		//add,xzg,2010/02/17,E---
		ShowMsgBox("AP9990014","AP9990004", MSGBOXB_OK, MSGBOXI_ERROR);
	}
	else if ("DISABLE"==vReason)
	{
		//add,xzg,2010/02/05,S---
		g_ResultCodeEx=1008;
		//add,xzg,2010/02/05,E---
		//add,xzg,2010/02/17,S---
		if(g_AcxOnConnect!=1)
		//add,xzg,2010/02/17,E---
		ShowMsgBox("AP9990015","AP9990004", MSGBOXB_OK, MSGBOXI_ERROR);
	}
	else if ("LN_OVER"==vReason)
	{
		//add,xzg,2010/02/05,S---
		g_ResultCodeEx=1009;
		//add,xzg,2010/02/05,E---
		//add,xzg,2010/02/17,S---
		if(g_AcxOnConnect!=1)
		//add,xzg,2010/02/17,E---
		ShowMsgBox("AP9990016","AP9990004", MSGBOXB_OK, MSGBOXI_ERROR);
	}
	else
	{
		//add,xzg,2010/02/05,S---
		g_ResultCodeEx=1010;
		//add,xzg,2010/02/05,E---
		//update,xzg,2009/04/15,S-------
		//ShowMsgBox("AP9990007","AP9990004", MSGBOXB_OK, MSGBOXI_ERROR);
		vErrMsg="AP9990004";
		//add,xzg,2010/02/17,S---
		if(g_AcxOnConnect!=1)
		//add,xzg,2010/02/17,E---
		ShowMsgBox("AP9990007 " + vErrMsg,
				"Logon", MSGBOXB_OK, MSGBOXI_ERROR);
		//update,xzg,2009/04/15,E-------
	}
	//if (vErrMsg!="")

	//update,xzg,2009/02/12,E-------
	//add,xzg,2010/02/17,S---
	if(g_AcxOnConnect==1)
	{
		g_ResultCode=0;
		objRetParams = CreateParams();
		//add,xzg,SFA,2010/09/15,S
		g_nAgentStatus=STATE_LOGOFF;
		g_PreAgentStatus=-1
		 g_PreCallStatus=-1
		//add,xzg,SFA,2010/09/15,E
		window.external.AcxSendEvent("OnChangeAgentState", objRetParams.GetParams());
		
	}
	//add,xzg,2010/02/17,E---
	// SetAgentStatus
	SetAgentStatus(STATE_LOGOFF);
	
}

//////////////////////////////////////////////////////////////////////
// Logoff

function CmdLogoff()
{
	// ShowMsgBox
if (1!=g_ReRoute)
{
//add,xzg,2009/05/18,S---
	g_iLogOff=1;
//add,xzg,2009/05/18,E---
	//nRet = ShowMsgBox("AP9990017", "AP9990018", MSGBOXB_OKCANCEL, MSGBOXI_QUESTION);
	//if(nRet != MSGBOXR_OK) return;
}
//add,xzg,2009/06/18,S---------
window.clearInterval(myKeepAliveTime);
//add,xzg,2009/06/18,E---------
	// UM_LOGOUT
	objUmParams = CreateParams();
	objUmParams.SetString("Reason", "Reason");
	SendEvent("UM_LOGOUT", objUmParams);
	// SetAgentStatus
	groupSend.options.length=0;
	SetAgentStatus(STATE_DISABLE);
}

function SmLogoffCnf(objSmParams)
{
	SmLogoff(objSmParams);
}

function SmLogoff(objSmParams)
{
	// CpfMsgClose
//add,xzg,Acx,S-----	
	Acx_OnServiceStopped(0);
//add,xzg,Acx,E-----

//add,xzg,acx,S---------
g_PreAgentStatus=-1;
g_PreCallStatus=-1;
//add,xzg,acx,E---------

	window.external.CpfMsgClose();
	// SetPanelTitle
	//window.external.SetPanelTitle("エージェントパネル - ログオフ");
	//window.external.SetPanelTitle("エージェントパネル");
	window.external.SetPanelTitle("AP0040001");
	window.external.SetPanelIcon(PANELICON_ERROR);
	//add,xzg,2009/12/28,S-------------
	groupSend.options.length=0;
	//add,xzg,2009/12/28,E-------------

	// SetAgentStatus
	g_iHelp=2;
	SetAgentStatus(STATE_LOGOFF);
	//add,xzg,2009/01/09,S-----
	if (1==g_ReRoute)
	{

		window.external.SleepWithMsg( 3000 ) ;
		CmdLogon();
		SetAgentStatus(STATE_DISABLE);
	}
	g_ReRoute=0;
	//add,xzg,2009/01/09,E-----

}


//////////////////////////////////////////////////////////////////////
// Activity

function SmActivity(objSmParams)
{
	// UM_ACTIVITY_RSP
	objUmParams = CreateParams();
	objUmParams.SetString("AgentStatusID", g_sAgentStatusId);
	objUmParams.SetString("Reason", "Reason");
	SendEvent("UM_ACTIVITY_RSP", objUmParams);
}


//////////////////////////////////////////////////////////////////////
// Status

function SmStatus(objSmParams)
{
	// SetAgentStatus

	if ( g_nAgentStatus == STATE_OFFERING || STATE_CONNECT || STATE_WORKTIME)
	{
		if ( g_OfferingWindow )	
		{
			window.external.SleepWithMsg( 100 );
			try{
			//g_OfferingWindow.OnCancelByOtherWindow() ;
				g_OfferingWindow.close() ;
			}
			catch(e)
			{
			
			}
			g_OfferingWindow = 0 ;
		}		

	}

	nStatus = objSmParams.GetIntDefault("iStatus", 0);
	vReason=objSmParams.GetStringDefault("vReason", "");
	if(nStatus == 13 ) nStatus = STATE_CONNECT;
	iNumberOfVmail=objSmParams.GetStringDefault("iNumberOfVmail","0");

	if (iNumberOfVmail>0)
		btnVoiceMail.className="PanelButtonMail1";
	else
		btnVoiceMail.className="PanelButtonMail0";
	
	iNumberOfQueCall=objSmParams.GetStringDefault("iNumberOfQueCall","0");
	if (iNumberOfQueCall>3)
		btnQueCall.className="PanelButtonQue2";
	else if (iNumberOfQueCall>0)
		btnQueCall.className="PanelButtonQue1";
	else
		btnQueCall.className="PanelButtonQue0";
//add,xzg,SFA,S
Acx_OnChangeQueVoice(iNumberOfVmail,iNumberOfQueCall);
//add,xzg,SFA,E
	//add,xzg,S
	//makecall music
/*
	objSound=document.getElementById("bgsound");
	if (STATE_NMCALLING==nStatus || STATE_TRANCALLING==nStatus)
		{
			//objSound.src="sounds/ring.wav";
			//objSound.loop=-1;
			//del,xzg,2009/02/03,S----
			//一時対応
			//objSound.play();
			//del,xzg,2009/02/03,E----
		}
	else
		{
			
			//objSound.src="sounds/ring.wav";
			//objSound.loop=-1;
			//del,xzg,2009/02/03,S----
			//一時対応
			//objSound.stop();
			//del,xzg,2009/02/03,E----
		}
STATE_CALLING==nStatus ||
*/
	objSound=document.getElementById("divSound");
	if (STATE_NMCALLING==nStatus || STATE_TRANCALLING==nStatus )
	{
		//update,xzg,SFA,S
		//if (playVoice==0)
		if (playVoice==0 && g_ClientName!="SFA")
		//update,xzg,SFA,E
		{
			objSound.innerHTML='<embed id="bgsound1" src="sounds/ring.wav" loop="true" autostart="true" style="width:0px;height:0px;visibility:hidden;">';
			playVoice=1;
		}

	}
	else
	{
		objSound.innerHTML='<embed id="bgsound2" src="sounds/ring.wav" loop="true" autostart="false" style="width:0px;height:0px;visibility:hidden;">';
		playVoice=0
	}
	if (g_iCallBack ==1 && nStatus==STATE_WORKTIME)
	{
		g_iCallBack=0;
		closeCallBack();
		
	}
//add,xzg,SFA,2009/12/14,S-----
	skyCallID=objSmParams.GetStringDefault("iSessionProfileID","0");

	if (g_iMakeCall ==1 && nStatus==STATE_WORKTIME)
	{
		g_iMakeCall=0;
		
		closeMakeCall(vReason,g_EventID);
	}
//add,xzg,SFA,2009/12/14,E-----
	var strMsg="";
	if (vReason.length>0)
	{
		if(REQUEST_403==vReason)
		{
			strMsg=window.external.GetLangText("AP0040037");
			strMsg=strMsg + "(403)";
			InfoMsg.innerText=strMsg;
			//add,xzg,Acx,S-----
			Acx_OnCallFailed(objSmParams,403);
			//add,xzg,Acx,E-----
		}
		else if(REQUEST_486==vReason)
		{
			strMsg=window.external.GetLangText("AP0040038");
			strMsg=strMsg + "(486)";
			InfoMsg.innerText=strMsg;
			//add,xzg,Acx,S-----
			Acx_OnCallFailed(objSmParams,486);
			//add,xzg,Acx,E-----
		}
		else
		{
			if (vReason>=REQUEST_400)
			{
				if (null!=vReason.match(/^[0-9]+$/))
					{
						strMsg=window.external.GetLangText("AP0040037");
						strMsg=strMsg + "(" + vReason  + ")";
						InfoMsg.innerText=strMsg;
						//add,xzg,Acx,S-----
						Acx_OnCallFailed(objSmParams,parseInt(vReason));
						//add,xzg,Acx,E-----
					}

				
			}
		}
	}
	//add,xzg,E
	//add,xzg,2009/12/21,S------------
	g_nAgentStatus = nStatus;
	Acx_OnChangeAgentState(objSmParams);
	//add,xzg,2009/12/21,E------------
	//add,xzg,acx,S---
	if (STATE_CONNECT==nStatus)
	{
	Acx_OnConnected(objSmParams);
	}
	//add,xzg,acx,E----
	SetAgentStatus(nStatus);

	
}

//////////////////////////////////////////////////////////////////////
// Wait

function CmdBgnWait()
{
	// UM_BGN_WAIT
	objUmParams = CreateParams();
	SendEvent("UM_BGN_WAIT", objUmParams);
	SetAgentStatus(STATE_DISABLE);
}


//////////////////////////////////////////////////////////////////////
// SeatOff

function CmdBgnSeatoff()
{
	// UM_BGN_LEAVE
	objUmParams = CreateParams();
	objUmParams.SetString("Reason", "Reason");
	SendEvent("UM_BGN_LEAVE", objUmParams);
	SetAgentStatus(STATE_DISABLE);
}

//////////////////////////////////////////////////////////////////////
// Worktime

function CmdBgnWorktime()
{
	// UM_BGN_WORKTIME
	objUmParams = CreateParams();
	objUmParams.SetString("Reason", "Reason");
	SendEvent("UM_BGN_WORKTIME", objUmParams);
	SetAgentStatus(STATE_DISABLE);
}

//////////////////////////////////////////////////////////////////////
// Offering
function SmOfferingAck()
{
	objUmParams = CreateParams();
	objUmParams.SetString("AgentStatusID", g_sAgentStatusId);
	SendEvent("UM_OFFERING_ACK", objUmParams);
	SetAgentStatus(STATE_DISABLE);
}
function SmOfferingNak()
{
	objUmParams = CreateParams();
	objUmParams.SetString("AgentStatusID", g_sAgentStatusId);
	SendEvent("UM_OFFERING_NAK", objUmParams);
	SetAgentStatus(STATE_DISABLE);
}

function SmOfferingInd(objSmParams)
{
	//add,xzg,2010/02/09,S------
	g_CallType="2";
	//add,xzg,2010/02/09,E------

	// ノーマル表示にします
//add,xzg,2010/02/10,S----------
if(g_AcxOnConnect==0 || window.external.GetPanelMin()==1)
{
//add,xzg,2010/02/10,E----------
	window.external.SetPanelState(PANELSTATE_NORMAL);
}

	// ShowBalloonTip
	// window.external.ShowBalloonTip("着信", objSmParams.GetStringDefault("CustomerName", ""), TIPICON_INFO);
	// ShowDialog agentpanel_offering
/*
	sRet = window.external.ShowModalDialog(
				"agentpanel_offering.htm", objSmParams,
				"dialogWidth:250px;dialogHeight:160px;center:yes;status:no");
	// UM_OFFERING
	objUmParams = CreateParams();
	objUmParams.SetString("AgentStatusID", g_sAgentStatusId);
	if(sRet == "ok")
	{
		SendEvent("UM_OFFERING_ACK", objUmParams);
		SetAgentStatus(STATE_DISABLE);
	}
	else
	{
		SendEvent("UM_OFFERING_NAK", objUmParams);
	}
*/

//add,xzg,2009/11/04,S---------
//add,xzg,2010/02/10,S----------
if(g_AcxOnConnect==0 || window.external.GetPanelMin()==1)
{
//add,xzg,2010/02/10,E----------
	window.external.showMe();
//add,xzg,2010/02/10,S----------
}
//add,xzg,2010/02/10,E----------
//add,xzg,2009/11/04,E---------
	g_vCallerID 	= objSmParams.GetStringDefault("vCallerID", "");
	g_CustomerName 	= objSmParams.GetStringDefault("CustomerName", "");
//add,xzg,2009/05/15,S---------
	g_iTimeOut 	= objSmParams.GetStringDefault("iTimeout", "0");
	//add,xzg,2009/05/15,E---------
	//add,xzg,2008/05/21,S---------
	hasOption=0;
	for (i=0;i<callerList.options.length;i++){
		if(callerList.options[i].value==g_vCallerID){
			hasOption=1;
			break;
		}
	}
	if (hasOption==0){
		var oOption=new Option(g_vCallerID ,g_vCallerID )
		callerList.add(oOption);
	}
	//add,xzg,2008/05/21,E---------
	g_vTel=g_vCallerID;
	//xzg,add
		msg1="";
		msg2=""
		nCaller = objSmParams.GetStringDefault("vCallerID", "");
		//nSkill = objSmParams.GetStringDefault("iSkillID", "");
		nSkill = objSmParams.GetStringDefault("vDistGroup", "");

		nGroup=objSmParams.GetStringDefault("vIncmGroup", "");
		g_vGrp=nGroup;
		g_vSkillGrp=nSkill;
//add,xzg,2009/12/21,S-----
Acx_OnOffering(objSmParams);
//add,xzg,2009/12/21,E-----
		
 		//神田商会
		//nGroup="神田着信"
		//nSkill="神田着信"
		msg1=window.external.GetLangText("AP0040040");
		msg1=msg1 + "(" + g_vSkillGrp + ")";
		msg1=msg1 + "  " + window.external.GetLangText("AP0040039")  + "(" + nGroup + ")";
		msg2=window.external.GetLangText("AP0040041") + "("+ nCaller + ")";
		//if (nSkill>0)	skill.value=nSkill;
		//skill.value=nSkill;
		//if (nGroup<>0) group.value=nGroup;
		//if (nCaller>0)  caller.value=nCaller;
		if (nGroup!="") Msg.innerText= msg1;
		if (nCaller!="") InfoMsg.innerText=msg2;
		//InfoMsg.innerText=msg2;
		//add,xzg,2009/10/07,S-------
		g_objOffParams=objSmParams;
		//add,xzg,2009/10/07,E-------
		//add,xzg,2009/12/01,ty
//add,xzg,2010/02/10,S----------
//if(g_AcxOnConnect==0 || window.external.GetPanelMin()==1)
//xzg,SFA,S
if(g_AcxOnConnect==0 || window.external.GetPanelMin()==1 || g_ClientName=="SFA")
//xzg,SFA,E
{

//add,xzg,2010/02/10,E----------
		ty=objSmParams.GetStringDefault("vFuncType", "0");	
		g_OfferingWindow = window.external.ShowModelessDialog(
				"agentpanel_offering.asp?ln=" + hLanguage.value + "&ty=" + ty, 
				window,
				"dialogWidth:250px;dialogHeight:250px;center:yes;status:no");
		g_OfferingWindow.focus();
		
}
}

//////////////////////////////////////////////////////////////////////
// Connect

function CmdConnect()
{
	
	//update,xzg,2009/06/25,S----
	//tel=telNo.value;
	if (callerList.style.visibility!="hidden") 
	{
		tel=callerList.value;
	}
	else
	{
		tel=telNo.value;
	}
	//add,xzg,2010/01/20,S---
	if (tel==null) tel="";
	//add,xzg,2010/01/20,E---

	//update,xzg,2009/06/25,E----
//update,xzg,2009/08/20,S
	//tel=tel.replace(" ","");
	//tel=tel.replace("@","");
	//update,xzg,2009/12/11,S--------
	//if (tel.length<1) return;
	if (tel.length<1)
	{
		//add,xzg,2010/02/10,S----
		if (g_AcxOnConnect!=1)
		{
		//add,xzg,2010/02/10,E----

		tel=window.clipboardData.getData('text');
		if (tel.length<1) return;
		if (!window.confirm(tel + "に発信しますか？")) return;
		}
		Acx_OnMakeCallRequest();
	}
	if (tel.length<1) return;
	//update,xzg,2009/12/11,E--------
	tel=tel.replace(new RegExp("[^0-9]","gm"),"");
//update,xzg,2009/08/20,E
//add,xzg,2009/08/20,S
	Msg.innerText="Tel:" + tel;
//add,xzg,2009/08/20,E

	if (tel.length<1) return;
	window.external.showMe();
	// UM_AGENT_LIST
	objUmParams = CreateParams();
	objUmParams.SetString("AgentStatusID", g_sAgentStatusId);
	objUmParams.SetString("iniFile", "iniFile");
	objUmParams.SetString("Section", "Section");
	objUmParams.SetString("Parameter", "Parameter");
	SendEvent("UM_AGENT_LIST", objUmParams);
}

function SmAgentListResult(objSmParams)
{
	// agentpanel_dial
	/* xzg
	sRet = window.external.ShowModalDialog(
				"agentpanel_dial.htm", objSmParams.GetStringDefault("ID1", ""),
				"dialogWidth:230px;dialogHeight:280px;center:yes;status:no");
	if(sRet == "cancel") return;
	*/
	// UM_CONNECT
	objUmParams = CreateParams();
//	objUmParams.SetString("AgentStatusID", g_sAgentStatusId);
//	objUmParams.SetString("InfoType", "InfoType");
//	objUmParams.SetString("ListResult", sRet);
	//objUmParams.SetString("vAddr", sRet);
	
	//update,xzg,2009/06/25,S----
	//tel=telNo.value;
	if (callerList.style.visibility!="hidden") 
	{
		tel=callerList.value;
	}
	else
	{
		tel=telNo.value;
	}
	//update,xzg,2009/06/25,E----
//update,xzg,2009/08/20,S
	//tel=tel.replace(" ","");
	//tel=tel.replace("@","");
	//update,xzg,2009/12/11,S--------
	//if (tel.length<1) return;
	if (tel.length<1)
	{
		tel=window.clipboardData.getData('text');
		if (tel.length<1) return;		
	}

	//update,xzg,2009/12/11,E--------
	tel=tel.replace(new RegExp("[^0-9]","gm"),"");
	if (tel.length<1) return;
//update,xzg,2009/08/20,E
	if ( g_nAgentStatus == STATE_HOLDING )
	{
		sAgentStatusID	=	"TRAN#" + tel ;
		objUmParams.SetString("iAgentStatusID", sAgentStatusID);
		SendEvent("UM_FORWARD", objUmParams);
	}
	else
	{
		groupid=groupSend.value;
		if (groupid.length>0)
			objUmParams.SetString("iGroupID", groupid);
		objUmParams.SetString("vAddr", tel);
		SendEvent("UM_CONNECT", objUmParams);
	//add,xzg,2010/02/02,S----
		g_CallType="1";
	//add,xzg,2010/02/02,E----
	}
	SetAgentStatus(STATE_DISABLE);
	//add,xzg,2008/05/21,S---------
	hasOption=0;
	for (i=0;i<callerList.options.length;i++){
		if(callerList.options[i].value==tel){
			hasOption=1;
			break;
		}
	}
	if (0==hasOption){
		var oOption=new Option(tel,tel)
		callerList.add(oOption);
	}


	//add,xzg,2008/05/21,E---------
}

function SmConnectCnf(objSmParams)
{
}

//////////////////////////////////////////////////////////////////////
// Disconnect

function CmdDisconnect()
{
	// UM_DISCONNECT
	objUmParams = CreateParams();
	SendEvent("UM_DISCONNECT", objUmParams);
	//add,xzg,SFA,2010/06/17,skyCall,S-------
if (g_iMakeCall ==1 && (STATE_CALLING==g_nAgentStatus || STATE_NMCALLING==g_nAgentStatus ))
	{
		g_iMakeCall=0;
		closeMakeCall("6",g_EventID);
	}
//add,xzg,SFA,2010/06/17,skyCall,E-------
	SetAgentStatus(STATE_DISABLE);
}

function SmDisconnectCnf(objSmParams)
{
//add,xzg,acx,S----
Acx_OnDisconnected(objSmParams);
//add,xzg,acx,E----
}

//////////////////////////////////////////////////////////////////////
// Hold

function CmdBgnHold()
{
	// UM_BGN_HOLD
	//add,xzg,2009/04/14,S----
	window.external.SleepWithMsg( 100 );
	//add,xzg,2009/04/14,E----
	objUmParams = CreateParams();
	objUmParams.SetString("vASI","HOLDCALL" );
	objUmParams.SetString("vParams", "vParams");
	objUmParams.SetString("iShakeOff", "0");
	SendEvent("UM_BGN_HOLD", objUmParams);
	SetAgentStatus(STATE_DISABLE);
}

function CmdEndHold()
{
	// UM_END_HOLD
	//add,xzg,2009/04/14,S----
	window.external.SleepWithMsg( 100 );
	//add,xzg,2009/04/14,E----
	objUmParams = CreateParams();
	objUmParams.SetString("iRetrieveRule", "0");
	SendEvent("UM_END_HOLD", objUmParams);
	SetAgentStatus(STATE_DISABLE);
}

//////////////////////////////////////////////////////////////////////
// Forward

function CmdGetList()
{
	// UM_FORWARD_LIST
	objUmParams = CreateParams();
	objUmParams.SetString("AgentStatusID", g_sAgentStatusId);
//	objUmParams.SetString("iniFile", "/usr/local/ngcp/etc/CallCtrl.ini");
//	objUmParams.SetString("Section", "Transfer");
//	objUmParams.SetString("Parameter", ";iAgentStatus=0");

	objUmParams.SetString("vIniFile", "/usr/local/ngcp/etc/CallCtrl.ini");
	objUmParams.SetString("vSection", "Transfer");
	objUmParams.SetString("vParameter", ";iAgentStatus=0");

	SendEvent("UM_GET_LIST", objUmParams);
	//update,xzg,2010/01/12,S-----
	//SetAgentStatus(STATE_DISABLE);
	if (g_cmdGetList==1) SetAgentStatus(STATE_DISABLE);		
	//update,xzg,2010/01/12,E-----
	// List clear
	g_objListParams.Clear();
	g_nListCnt = 0;
}

function SmGetListResult(objSmParams)
{
	// Add List
	nCount = objSmParams.GetInt("Count");
	for(i = 1; i <= nCount; i++)
	{
		sID = objSmParams.GetString("ID" + String(i));
		sDisp = objSmParams.GetString("Disp" + String(i));
		g_nListCnt = g_nListCnt + 1;
		g_objListParams.SetString("ID" + String(g_nListCnt), sID);
		g_objListParams.SetString("Disp" + String(g_nListCnt), sDisp);
	}
	if(objSmParams.GetStringDefault("Continue", "S") == "C") return;
	sSection = objSmParams.GetStringDefault("vSection", "Transfer");
	
	// 選択ダイヤログ
	g_objListParams.SetInt("Count", g_nListCnt);
	//add,xzg,2009/12/28,S---------
	if (g_cmdGetList==0)
	{
		g_objAgentList=g_objListParams;
		g_getAgentList=1;
		return;	
	}
	//add,xzg,2009/12/28,E---------
	if(sSection == "Message")
	{
		sRet = window.external.ShowModalDialog(
				"agentpanel_select_chat.htm", g_objListParams,
				"dialogWidth:600px;dialogHeight:300px;center:yes;status:no");
	}
	else
	{
		sRet = window.external.ShowModalDialog(
				"agentpanel_select_forward.asp?ln=" + hLanguage.value, window,
				"dialogWidth:250px;dialogHeight:150px;center:yes;status:no");
	}

	objUmParams = CreateParams();
	objUmParams.SetString("AgentStatusID", g_sAgentStatusId);

	// UM_FORWARD
	if(sSection == "Transfer")
	{
		if(sRet != "cancel")
		{
	//add,xzg,2010/02/09,S---------------
	objUmParams1 = CreateParams();
	objUmParams1.SetString("iSessionProfileID", g_EventID);
	objUmParams1.SetString("iMatterID", g_CallType);
	SendEvent("UM_SET_CUST_INFO", objUmParams1);
	//add,xzg,2010/02/09,E---------------
			objUmParams.SetString("iAgentStatusID", sRet);
			objUmParams.SetString("vMediaType", "1");
			SendEvent("UM_FORWARD", objUmParams);
			SetAgentStatus(STATE_DISABLE);
		}
		else
		{
			SetAgentStatus( STATE_HOLDING );
		}
//		else
//		{
//			objUmParams.SetString("vReason", "vReason");
//			SendEvent("UM_CANCEL_FORWARD", objUmParams);
//			SetAgentStatus(STATE_DISABLE);
//		}
	}
	else if(sSection == "Conference"){
	}
	else if(sSection == "Monitoring"){
	}
	else if(sSection == "Message"){
		if(sRet != "cancel"){
//			sMessage = p_sDisplayName.value + ">" + InputBox("Message");
//			sMessage = p_sDisplayName.value + ">" + "メッセージ";
			sMessage =  sRet ;
			objUmParams.SetString("vMessage", sMessage);
			nCount = 1;
			str = "ok" ;
			objUmParams.SetString("Count", String(nCount));

			for(i=1; i<=nCount; i++)
			{
				objUmParams.SetString("ID" + String(i), str );
			}
			SendEvent("UM_MESSAGE", objUmParams);
		}
	}
	else
	{
		if(sRet != "cancel")
		{
	//add,xzg,2010/02/09,S---------------
	objUmParams1 = CreateParams();
	objUmParams1.SetString("iSessionProfileID", g_EventID);
	objUmParams1.SetString("iMatterID", g_CallType);
	SendEvent("UM_SET_CUST_INFO", objUmParams1);
	//add,xzg,2010/02/09,E---------------
			objUmParams.SetString("iAgentStatusID", sRet);
			objUmParams.SetString("vMediaType", "1");
			SendEvent("UM_FORWARD", objUmParams);
			SetAgentStatus(STATE_DISABLE);
		}
		else
		{
			SetAgentStatus( STATE_HOLDING );
		}
//		else
//		{
//			objUmParams.SetString("vReason", "vReason");
//			SendEvent("UM_CANCEL_FORWARD", objUmParams);
//			SetAgentStatus(STATE_DISABLE);
//		}
	}
}

function CmdCancelForward()
{
	//add,xzg,2010/02/09,S----------
	g_TransConnected="0";
	//add,xzg,2010/02/09,E----------

	// UM_CANCEL_FORWARD
	objUmParams = CreateParams();
	objUmParams.SetString("vReason", "vReason");
	SendEvent("UM_CANCEL_FORWARD", objUmParams);
	SetAgentStatus(STATE_DISABLE);
}

function SmForwardAck(objSmParams)
{
}

function SmForwardNak(objSmParams)
{
	nRet = ShowMsgBox("AP9990019", "AP9990020", MSGBOXB_OKCANCEL, MSGBOXI_QUESTION);
}

function SmForwardErr(objSmParams)
{
	nRet = ShowMsgBox("AP9990021", "AP9990020", MSGBOXB_OKCANCEL, MSGBOXI_QUESTION);
}

function SmMonitoringAck(objSmParams)
{
}

function SmMonitoringNak(objSmParams)
{
	nRet = ShowMsgBox("AP9990022", "AP9990023", MSGBOXB_OKCANCEL, MSGBOXI_QUESTION);
}

function SmMeetingAck(objSmParams)
{
}

function SmMeetingNak(objSmParams)
{
	nRet = ShowMsgBox("AP9990024", "AP9990025", MSGBOXB_OKCANCEL, MSGBOXI_QUESTION);
}

function CmdForwardCnf()
{
	//add,xzg,2010/02/09,S----------
	g_TransConnected="1";
	//add,xzg,2010/02/09,E----------

	// UM_FORWARD_CNF
	objUmParams = CreateParams();
	SendEvent("UM_FORWARD_CNF", objUmParams);
	SetAgentStatus(STATE_DISABLE);
}

function SmForwardInd(objSmParams)
{
	// ShowModalDialog
	sRet = window.external.ShowModalDialog(
				"agentpanel_forwardind.htm", objSmParams,
				"dialogWidth:600px;dialogHeight:300px;center:yes;status:no");
	// UM_FORWARD_ACK
	objUmParams = CreateParams();
	objUmParams.SetString("AgentStatusID", g_sAgentStatusId);
	if(sRet == "ok")
	{
		objUmParams.SetString("Reason", "Reason");
		SendEvent("UM_FORWARD_ACK", objUmParams);
		SetAgentStatus(STATE_DISABLE);
	}
	else
	{
		objUmParams.SetString("Reason", "Reason");
		SendEvent("UM_FORWARD_NAK", objUmParams);
	}
}

//////////////////////////////////////////////////////////////////////
// Play

function CmdPlay()
{
	// UM_PLAY_LIST
	objUmParams = CreateParams();
	objUmParams.SetString("AgentStatusID", g_sAgentStatusId);
	objUmParams.SetString("iniFile", "iniFile");
	objUmParams.SetString("Section", "Section");
	objUmParams.SetString("Parameter", "Parameter");
	SendEvent("UM_PLAY_LIST", objUmParams);
	// List clear
	g_objListParams.Clear();
	g_nListCnt = 0;
}

function SmPlayListResult(objSmParams)
{
	// Add List
	nCount = objSmParams.GetInt("Count");
	for(i = 1; i < nCount; i++)
	{
		sID = objSmParams.GetString("ID" + String(i));
		sDisp = objSmParams.GetString("Disp" + String(i));
		g_nListCnt = g_nListCnt + 1;
		g_objListParams.SetString("ID" + String(g_nListCnt), sID);
		g_objListParams.SetString("Disp" + String(g_nListCnt), sDisp);
	}
	if(objSmParams.GetStringDefault("Continue", "S") == "C") return;
	
	// 選択ダイヤログ
	/*xzg
	g_objListParams.SetInt("Count", g_nListCnt);
	sRet = window.external.ShowModalDialog(
				"agentpanel_select_play.htm", g_objListParams,
				"dialogWidth:600px;dialogHeight:300px;center:yes;status:no");
	if(sRet == "cancel") return;
	*/
	// UM_PLAY
	objUmParams = CreateParams();
	objUmParams.SetString("AgentStatusID", g_sAgentStatusId);
/*
	msg=sendMsg.value;
	objUmParams.SetString("ListResult", msg);
	SendEvent("UM_PLAY", objUmParams);
*/

}

//////////////////////////////////////////////////////////////////////
// Record

// 通話録音開始
function CmdBgnRecord()
{
	// UM_BGN_RECORDING
	objUmParams = CreateParams();
	SendEvent("UM_BGN_RECORDING", objUmParams);
	SetAgentStatus(STATE_DISABLE);
}

// 通話録音終了
function CmdEndRecord()
{
	// UM_END_RECORDING
	objUmParams = CreateParams();
	SendEvent("UM_END_RECORDING", objUmParams);
	SetAgentStatus(STATE_DISABLE);
}

// 録音終了通知
function SmEndRecording(objSmParams)
{
	sRecFile = objSmParams.GetString("iBoxProfileID");
}
// NGCPが再起動された
function SmRebooted(objSmParams)
{
	//add,xzg,2010/03/02,S-----
	g_RebootAgentStatus=g_nAgentStatus;
	//add,xzg,2010/03/02,E-----

	//add,xzg,2009/10/22,S--
	g_iLogOff=1;
	//add,xzg,2009/10/22,E--
	SmLogoff()
//	alert("Rebooted from NGCP Server");
	window.external.SleepWithMsg( 3000 ) ;
	CmdLogon()
//	sRecFile = objSmParams.GetString("iBoxProfileID");
//	MsgBox "REBOOTED"
}

//////////////////////////////////////////////////////////////////////
// Conference

function CmdConference()
{
	// UM_GET_LIST
	objUmParams = CreateParams();
	objUmParams.SetString("vIniFile", "/usr/local/ngcp/etc/CallCtrl.ini");
	objUmParams.SetString("vSection", "Conference");
	objUmParams.SetString("vParameter", ";iAgentStatus=0");
	if ( g_iHelp ==  0 )
	{
		SendEvent("UM_HELP_ON", objUmParams);
		g_iHelp = 1 ;
	}
	else
	{
		SendEvent("UM_HELP_OFF", objUmParams);
		g_iHelp = 0 ;
	}	
	// List clear
	g_objListParams.Clear();
	g_nListCnt = 0;
}

// 会議解除
function CmdCancelMeeting()
{
	// UM_CANCEL_MEETING
	objUmParams = CreateParams();
	objUmParams.SetString("vReason", "vReason");
	SendEvent("UM_HELP_OFF", objUmParams);
	SetAgentStatus(STATE_DISABLE);
}

// 会議退室
function CmdMeetingLeave()
{
	// UM_MEETING_LEAVE
	objUmParams = CreateParams();
	objUmParams.SetString("vReason", "vReason");
	SendEvent("UM_HELP_OFF", objUmParams);
	SetAgentStatus(STATE_DISABLE);
}

// 会議完了
function CmdConferenceCnf()
{
	// UM_MEETING_CNF
	objUmParams = CreateParams();
	SendEvent("UM_HELP_OFF", objUmParams);
	SetAgentStatus(STATE_DISABLE);
}

//////////////////////////////////////////////////////////////////////
// Monitor

function CmdMonitor()
{
	// UM_GET_LIST
	objUmParams = CreateParams();
	objUmParams.SetString("vIniFile", "/usr/local/ngcp/etc/CallCtrl.ini");
	objUmParams.SetString("vSection", "Monitoring");
	objUmParams.SetString("vParameter", ";iAgentStatus=4");
	SendEvent("UM_GET_LIST", objUmParams);
	// List clear
	g_objListParams.Clear();
	g_nListCnt = 0;
}

//////////////////////////////////////////////////////////////////////
// Message
function CmdMessage()
{

	// UM_GET_LIST

	objUmParams = CreateParams();
/*update,xzg
	objUmParams.SetString("vIniFile", "/usr/local/ngcp/etc/CallCtrl.ini");
	objUmParams.SetString("vSection", "Message");
	objUmParams.SetString("vParameter", ";iAgentStatus=0");
	SendEvent("UM_GET_LIST", objUmParams);
*/
	sMessage=sendMsg.value;
	if (sMessage.length<1) return;
	if (recMsg.innerText.length>0)
	{
		recMsg.innerText=recMsg.innerText + "\r\n" + "<" + sMessage;
	}
	else
	{
		recMsg.innerText= "<" + sMessage;
	}
	recMsg.scrollTop=recMsg.scrollHeight;
	objUmParams.SetString("vMessage", sMessage);
	SendEvent("UM_MESSAGE", objUmParams);
	sendMsg.value="";

	// List clear
	g_objListParams.Clear();
	g_nListCnt = 0;
}

function SmMessageInd(objSmParams)
{
	//update,xzg
	//ShowMsgBox(objSmParams.GetStringDefault("vMessage", ""), "管理者から", MSGBOXB_OK, MSGBOXI_INFORMATION);
	msg=objSmParams.GetStringDefault("vMessage", "");
	//add,xzg,2009/12/28,S--------
	Acx_OnDataReceived(msg);
	//add,xzg,2009/12/28,E--------
	//recMsg.value=recMsg.value + "\r\n" + msg;
	if (recMsg.innerText.length>0)
	{
		recMsg.innerText=recMsg.innerText + "\r\n" + ">" + msg;
	}
	else
	{
		recMsg.innerText= ">" + msg;
	}
	
	recMsg.scrollTop=recMsg.scrollHeight;
	//xzg,SFA,S
	try
	{
		if(g_ClientName!="SFA") return;
		if (g_PChat!=null)
		{

			if (win_closed(g_PChat))
			{
				g_PChat = window.open('agentpanel_Chat.asp', "Chat",
					'height=200px,width=400px,left=10,top=100,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
			}
			g_PChat.focus();
			g_PChat.recMsg.innerText=recMsg.innerText;
			g_PChat.recMsg.scrollTop=g_PChat.recMsg.scrollHeight;
		}
		
		else
		{

			if (win_closed(g_PChat))
			{
				g_PChat = window.open('agentpanel_Chat.asp', "Chat",
					'height=200px,width=400px,left=10,top=100,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
			}
			g_PChat.focus();
			g_PChat.recMsg.innerText=recMsg.innerText
			g_PChat.recMsg.scrollTop=g_PChat.recMsg.scrollHeight;
	}
	}
	catch(e)
		{
			g_PChat==null;
		}
	//xzg,SFA,E
}

//////////////////////////////////////////////////////////////////////
//SmReroute
//add,xzg,S
function SmReroute(objSmParams)
{
	//add,xzg,2010/03/02,S-----------
	g_RebootAgentStatus=g_nAgentStatus;
	//add,xzg,2010/03/02,E-----------
	sIpAddr=objSmParams.GetStringDefault("sIpAddr", "");
	iPort=objSmParams.GetStringDefault("iPort", "");
	sServer=objSmParams.GetStringDefault("sServer", "");
	hServerUrl.value=sIpAddr;
	hServerPort.value=iPort;
	hServerName.value=sServer;
	g_ReRoute=1;
	//add,xzg,2009/10/22,S---
	g_iLogOff=1;
	//add,xzg,2009/10/22,E---
	CmdLogoff();
		
}
//add,xzg,E

//////////////////////////////////////////////////////////////////////
// Offhook

function CmdOffhook()
{
	// UM_ANSWERCALL
	objUmParams = CreateParams();
	SendEvent("UM_ANSWERCALL", objUmParams);
	SetAgentStatus(STATE_DISABLE);
}


//////////////////////////////////////////////////////////////////////
//Record
function CmdRecordList()
{
/*update,xzg,2010/07/20,S-------------
	//sRet = window.open('agentpanel_record.asp?u='+ agent, 'Record',
	//			'height=700px,width=800px,left=10,top=10,menubar=no,toolbar=no,scrollbars=yes;');
	//sRet = window.open('https://DL360-W2K3-01/AgentPanel/agentpanel_record.asp?u='+ agent, 'Record',
	agent=objProfile.GetStringDefault("sAgentId", "No");

	if (g_PRecord==null)
	{
		g_PRecord = window.open('agentpanel_record.asp?u='+ agent + '&ln=' + hLanguage.value, "",
			'height=600px,width=700px,left=10,top=10,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');

	}
	else
	{
		if (win_closed(g_PRecord))
		{
			g_PRecord = window.open('agentpanel_record.asp?u='+ agent + '&ln=' + hLanguage.value, "",
				'height=600px,width=700px,left=10,top=10,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
		}
	g_PRecord.focus();
	}


update,xzg,2010/07/20,E-------------*/
	if (hVer.value=="2.3" || hVer.value=="3.1" )  window.external.ShowRecord(window);
	else {
		agent=objProfile.GetStringDefault("sAgentId", "No");

		if (g_PRecord==null)
		{
			g_PRecord = window.open('agentpanel_record.asp?u='+ agent + '&ln=' + hLanguage.value, "",
			'height=600px,width=700px,left=10,top=10,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');

		}
		else
		{
			if (win_closed(g_PRecord))
			{
				g_PRecord = window.open('agentpanel_record.asp?u='+ agent + '&ln=' + hLanguage.value, "",
				'height=600px,width=700px,left=10,top=10,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
			}
			g_PRecord.focus();
		}
	}
	

}
//////////////////////////////////////////////////////////////////////
//CallBack
function CmdCallBack()
{
/*update,xzg,2010/07/20,S-------------
	agent=objProfile.GetStringDefault("sAgentId", "No");
	if (g_PCallBack==null)
	{

			g_PCallBack = window.open('agentpanel_callback.asp?u=' + agent + '&ln=' + hLanguage.value, '',
				'height=600px,width=700px,left=10,top=10,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
	}
	else
	{
		if (win_closed(g_PCallBack))
		{
			g_PCallBack = window.open('agentpanel_callback.asp?u=' + agent + '&ln=' + hLanguage.value, '',
				'height=600px,width=700px,left=10,top=10,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
		}
		g_PCallBack.focus();
	}
update,xzg,2010/07/20,E-------------*/
	if (hVer.value=="2.3" || hVer.value=="3.1" )  window.external.ShowCallBack(window);
	else {
		agent=objProfile.GetStringDefault("sAgentId", "No");
		if (g_PCallBack==null)
		{

			g_PCallBack = window.open('agentpanel_callback.asp?u=' + agent + '&ln=' + hLanguage.value, '',
				'height=600px,width=700px,left=10,top=10,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
		}
		else
		{
			if (win_closed(g_PCallBack))
			{
			g_PCallBack = window.open('agentpanel_callback.asp?u=' + agent + '&ln=' + hLanguage.value, '',
				'height=600px,width=700px,left=10,top=10,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
			}
			g_PCallBack.focus();
		}
	}	
		
}

//////////////////////////////////////////////////////////////////////
//close CallBack
function closeCallBack()
{
	//add,xzg,2010/07/20,S-------------
	if (hVer.value=="2.3" || hVer.value=="3.1"  )
	{
		window.external.closeCallback(g_CallbackID);
		return;
	}
	//add,xzg,2010/07/20,E-------------
	agent=objProfile.GetStringDefault("sAgentId", "No");
	if (g_PCallBack!=null)
	{
		if (!win_closed(g_PCallBack))
		{
			g_PCallBack.closeCallback(g_CallbackID);
		}
		else
		{
			g_PCallBack=window.open('agentpanel_callback.asp?u=' + agent + '&f=clickCallNew&c=' + g_CallbackID + '&v=2', 'CallBack',
				'height=600px,width=700px,left=10,top=10,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
		}
	}
	else
	{
		g_PCallBack=window.open('agentpanel_callback.asp?u=' + agent + '&f=clickCallNew&c=' + g_CallbackID + '&v=2', 'CallBack',
				'height=600px,width=700px,left=10,top=10,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
	}
	//sRet = window.open('agentpanel_callback.asp?u=' + agent + "&f=clickCall&c=' + g_CallbackID + '&v=2', 'CallBack',
	//			'height=600px,width=700px,left=10,top=10,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
	
}
//add,xzg,SFA,S
function closeMakeCall(makeCallStates,callSessionID)
{

	agent=objProfile.GetStringDefault("sAgentId", "No");
	tid=hTenantID.value;
	if (makeCallStates==null) makeCallStates="2";
	if (makeCallStates=="" || makeCallStates=="0" ) makeCallStates="2";
	if (null!=makeCallStates.match(/^[0-9]+$/)) v=2;
	else makeCallStates="2";
	if (g_MakeCall!=null)
	{
		if (!win_closed(g_MakeCall))
		{
			g_MakeCall.closeMakeCall(g_MakeCallID,makeCallStates,callSessionID);
		}
		else
		{
			g_MakeCall=window.open('agentpanel_call.asp?tid=' + tid + '&u=' + agent + '&f=clickCallNew&c=' + g_MakeCallID + '&v=' + makeCallStates, 'makecall',
				'height=650px,width=700px,left=10,top=50,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
		}
	}
	else
	{
		g_MakeCall=window.open('agentpanel_call.asp?tid=' + tid + '&u=' + agent + '&f=clickCallNew&c=' + g_MakeCallID + '&v=' + makeCallStates, 'makecall',
				'height=650px,width=700px,left=10,top=50,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
	}
	
}

//////////////////////////////////////////////////////////////////////
//MakeCall
function cmdMakeCall()
{
	agent=objProfile.GetStringDefault("sAgentId", "No");
	tid=hTenantID.value;
	if (g_MakeCall==null)
	{

			g_MakeCall = window.open('agentpanel_call.asp?tid=' + tid + '&u=' + agent + '&ln=' + hLanguage.value, 'makecall',
				'height=650px,width=700px,left=10,top=50,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
	}
	else
	{
		if (win_closed(g_MakeCall))
		{
			g_MakeCall = window.open('agentpanel_call.asp?tid=' + tid + '&u=' + agent + '&ln=' + hLanguage.value, 'makecall',
				'height=650px,width=700px,left=10,top=50,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
		}
		g_MakeCall.focus();
	}
}

function onClickHand()
{
	objUmParams = CreateParams();
	if (iHandShake=="1")
	{
		objUmParams.SetString("iHandShake","0");
	}
	else
	{
		objUmParams.SetString("iHandShake","1");
	}
	SendEvent("UM_HANDSHAKE", objUmParams);

}
function CmdOption()
{
	agent=objProfile.GetStringDefault("sAgentId", "No");

	if (g_POption==null)
	{

		g_POption=window.open('CustomOption.asp?u=' + agent + '&ln=' + hLanguage.value 
				+ '&t=' + hTenantID.value  
				+ '&tel=' + g_vTel, '',
				'height=200px,width=300px,left=10,top=70,menubar=no,toolbar=no,scrollbars=no,resizable=true;');
	}
	else
	{

		if (win_closed(g_POption))
		{
			g_POption=window.open('CustomOption.asp?u=' + agent + '&ln=' + hLanguage.value 
				+ '&t=' + hTenantID.value  
				+ '&tel=' + g_vTel, '',
				'height=200px,width=300px,left=10,top=70,menubar=no,toolbar=no,scrollbars=no,resizable=true;');
		}
		g_POption.focus();
	}

}

//////////////////////////////////////////////////////////////////////

//cmdCTRelease
function cmdCTRelease()
{
	
	if (STATE_CONNECT==g_nAgentStatus )
	{
	objUmParams = CreateParams();
	SendEvent("UM_DETACH_CALL", objUmParams);
	}
}
//add,xzg,SFA,E

function win_closed(winVar) 
{
    var ua = navigator.userAgent
    if( !!winVar )
        if( ( ua.indexOf('Gecko')!=-1 || ua.indexOf('MSIE 4')!=-1 )
             && ua.indexOf('Win')!=-1 ) 
             return winVar.closed
        else return typeof winVar.document != 'object'
    else return true
}

//add,xzg,2009/12/21,S----
//////////////////////////////////////////////////////////////////////
// CpfLpcSvrAcxa

function AcxOnConnect(nCnnId)
{
	g_AcxOnConnect=1;
	//add,xzg,2010/11/19,S
	g_AcxConnected=g_AcxConnected+1;
	//add,xzg,2010/11/19,E
	//logonの処理
	if (g_nAgentStatus!=1)
	{


	}
	//add,xzg,SFA,S
	//if (hVer.value=="2.3")
	Acx_OnOptionInfo();
	//add,xzg,SFA,E
	g_ResultCode=1;
}

function AcxOnDisconnect(nCnnId)
{
	//add,xzg,2010/11/19,S
	g_AcxConnected=g_AcxConnected-1
	if (g_AcxConnected<1)
	//add,xzg,2010/11/19,E
	g_AcxOnConnect=0;
	//add,xzg,SFA,S
	g_ClientName="";
	g_ClientVer="";
	//add,xzg,SFA,E	
	g_ResultCode=1;
}

//////////////////////////////////////////////////////////////////////
// メソッド

function Acx_Login(objArgParams)
{
	try
	{
		//add,xzg,2010/02/10,S----------
		if (g_nAgentStatus!=STATE_LOGOFF) 
		{
			g_ResultCode=0;
			g_ResultCodeEx=3100;
			return;
		}
		//add,xzg,2010/02/10,E----------

		//xzg,SFA,S
		g_ClientName=objArgParams.GetStringDefault("ClientName","");
		g_ClientVer=objArgParams.GetStringDefault("ClientVer","");
		p_sSoftPhone=objArgParams.GetStringDefault("isSoftPhone","No");

		//xzg,SFA,E
		CmdLogon();
		g_ResultCode=1;
	}
	catch(e)
	{
		g_ResultCode=0;	
	}
}

function Acx_Logout(objArgParams)
{
	try
	{
		//add,xzg,2010/02/10,S----------
		if (g_nAgentStatus==STATE_LOGOFF) 
		{
			g_ResultCode=0;
			g_ResultCodeEx=3100;
			return;
		}
		//add,xzg,2010/02/10,E----------
		 CmdLogoff();
		g_ResultCode=1;
	}
	catch(e)
	{
		g_ResultCode=0;	
	}
}

function Acx_SetAgentState(objArgParams)
{
try
{

	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus==STATE_LOGOFF) 
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	//add,xzg,2010/02/10,E----------
	nState = objArgParams.GetInt("nState");
	if (nState==4)
	{

		//CmdLogoff();
	}
	else if(nState==0)
	{
		//add,xzg,2010/02/10,S----------
		if (g_nAgentStatus!=STATE_WORKTIME && g_nAgentStatus!=STATE_SEATOFF) 
		{
			g_ResultCode=0;
			g_ResultCodeEx=3100;
			return;
		}
		//add,xzg,2010/02/10,E----------
		CmdBgnWait();
	}
	else if(nState==1)
	{
		//add,xzg,2010/02/10,S----------
		if (g_nAgentStatus!=STATE_SEATOFF && g_nAgentStatus!=STATE_WAIT) 
		{
			g_ResultCode=0;
			g_ResultCodeEx=3100;
			return;
		}
		//add,xzg,2010/02/10,E----------
		CmdBgnWorktime();
	}
	else if(nState==2)
	{
		//add,xzg,2010/02/10,S----------
		if (g_nAgentStatus!=STATE_WORKTIME && g_nAgentStatus!=STATE_WAIT) 
		{
			g_ResultCode=0;
			g_ResultCodeEx=3100;
			return;
		}
		//add,xzg,2010/02/10,E----------
		CmdBgnSeatoff();
	}
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}
	//SetAgentStatus(nStatus);
}

function Acx_Answer(objArgParams)
{
try
{
	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus==STATE_LOGOFF) 
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	//add,xzg,2010/02/10,E----------

	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus!=STATE_OFFERING && g_nAgentStatus!=STATE_TRANOFFERING )
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	//add,xzg,2010/02/10,E----------

	objUmParams = CreateParams();
	objUmParams.SetString("AgentStatusID", g_sAgentStatusId);
	SendEvent("UM_OFFERING_ACK", objUmParams);
	//SetAgentStatus(STATE_DISABLE);
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_Reject(objArgParams)
{
try{
	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus==STATE_LOGOFF) 
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	//add,xzg,2010/02/10,E----------

	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus!=STATE_OFFERING && g_nAgentStatus!=STATE_TRANOFFERING )
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	//add,xzg,2010/02/10,E----------

	objUmParams = CreateParams();
	objUmParams.SetString("AgentStatusID", g_sAgentStatusId);
	SendEvent("UM_OFFERING_NAK", objUmParams);
	//SetAgentStatus(STATE_DISABLE);
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}
//add,xzg,SFA,S------
function Acx_BusyCall(objArgParams)
{
try
{

	if (g_nAgentStatus==STATE_LOGOFF) 
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}



	if (g_nAgentStatus==STATE_CONNECT) 		
	{
		//CmdBgnHold();
	}
	else if (g_nAgentStatus==STATE_HOLDING) 		
	{
		
	}
	else
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}

	
	sDestAddres = objArgParams.GetStringDefault("sDestAddres","");
	sGroup=objArgParams.GetStringDefault("Group","");
	// objArgParams -> オプションデータ
	//telNo.value=sDestAddres;
	//CmdConnect();
	if (sGroup=="") sGroup=groupSend.value;
	objUmParams = CreateParams();
	
	sAgentStatusID	=	"TRAN#" + sDestAddres ;
	objUmParams.SetString("iAgentStatusID", sAgentStatusID);
	SendEvent("UM_FORWARD", objUmParams);
	
	g_ResultCode=1;

}
catch(e)
	{
		g_ResultCode=0;	
	}

}
//add,xzg,SFA,E------
function Acx_Call(objArgParams)
{
try
{
	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus==STATE_LOGOFF) 
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	//add,xzg,2010/02/10,E----------

	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus!=STATE_WORKTIME && g_nAgentStatus!=STATE_WAIT 
		&&  g_nAgentStatus!=STATE_SEATOFF
		&&  g_nAgentStatus!=STATE_HOLDING) 		
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	//add,xzg,2010/02/10,E----------

	sDestAddres = objArgParams.GetStringDefault("sDestAddres","");
	sGroup=objArgParams.GetStringDefault("Group","");
	// objArgParams -> オプションデータ
	//telNo.value=sDestAddres;
	//CmdConnect();
	if (sGroup=="") sGroup=groupSend.value;
	objUmParams = CreateParams();
	if ( g_nAgentStatus == STATE_HOLDING )
	{
		sAgentStatusID	=	"TRAN#" + sDestAddres ;
		objUmParams.SetString("iAgentStatusID", sAgentStatusID);
		SendEvent("UM_FORWARD", objUmParams);
	}	
	else
	{
		g_CallType="1";
		objUmParams.SetString("iGroupID",sGroup);
		objUmParams.SetString("vAddr", sDestAddres);
		SendEvent("UM_CONNECT", objUmParams);
	}
	g_ResultCode=1;

}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_Transfer(objArgParams)
{
try
{
	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus==STATE_LOGOFF) 
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	//add,xzg,2010/02/10,E----------

	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus!=STATE_HOLDING) 		
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	//add,xzg,2010/02/10,E----------

	sDestAddres = objArgParams.GetString("sDestAddres");
	/*
	telNo.value=sDestAddres;
	CmdConnect();
	*/
	//add,xzg,2010/02/09,S---------------
	objUmParams = CreateParams();
	objUmParams.SetString("iSessionProfileID", g_EventID);
	objUmParams.SetString("iMatterID", g_CallType);
	SendEvent("UM_SET_CUST_INFO", objUmParams);
	//add,xzg,2010/02/09,E---------------

	objUmParams = CreateParams();
	objUmParams.SetString("AgentStatusID", g_sAgentStatusId);
	objUmParams.SetString("iAgentStatusID", sDestAddres);
	objUmParams.SetString("vMediaType", "1");
	SendEvent("UM_FORWARD", objUmParams);
	//SetAgentStatus(STATE_DISABLE);
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}
//add,xzg,SFA,S----------------
function Acx_TransferAgent(objArgParams)
{
try
{

	if (g_nAgentStatus==STATE_LOGOFF)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	
	if (g_nAgentStatus!=STATE_HOLDING)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	
	g_cmdGetList=1;
	CmdGetList();
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}
//add,xzg,SFA,E----------------
function Acx_TransferComplete(objArgParams)
{
try
{
	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus==STATE_LOGOFF) 
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	//add,xzg,2010/02/10,E----------

	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus!=STATE_TRANSFERING) 		
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	//add,xzg,2010/02/10,E----------

	CmdForwardCnf();
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_TransferCancel(objArgParams)
{
try
{

	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus==STATE_LOGOFF) 
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	//add,xzg,2010/02/10,E----------

	//add,xzg,2010/02/10,S----------
	//update,xzg,SFA,S--
	//if (g_nAgentStatus!=STATE_TRANSFERING)
	if (g_nAgentStatus!=STATE_TRANSFERING && g_nAgentStatus!=STATE_TRANCALLING && g_nAgentStatus!=STATE_SWITCHING) 		
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	//update,xzg,SFA,E--
	//add,xzg,2010/02/10,E----------

	CmdCancelForward();
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_Disconnect(objArgParams)
{
try
{
	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus==STATE_LOGOFF) 
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	//add,xzg,2010/02/10,E----------

	//add,xzg,2010/02/10,S----------
	//add,xzg,SFA,g_nAgentStatus!=STATE_TRANSFERING && g_nAgentStatus!=STATE_TRANOFFERING
	if (g_nAgentStatus!=STATE_CONNECT && g_nAgentStatus!=STATE_CALLING
		&& g_nAgentStatus!=STATE_NMCALLING && g_nAgentStatus!=STATE_OFFERING 
		&& g_nAgentStatus!=STATE_TRANSFERING && g_nAgentStatus!=STATE_TRANOFFERING
		 )
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	//add,xzg,2010/02/10,E----------

	CmdDisconnect();
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_Hold(objArgParams)
{
try
{
	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus==STATE_LOGOFF) 
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	//add,xzg,2010/02/10,E----------

	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus!=STATE_CONNECT)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	//add,xzg,2010/02/10,E----------
	CmdBgnHold();
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_UnHold(objArgParams)
{
try
{
	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus==STATE_LOGOFF) 
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	//add,xzg,2010/02/10,E----------

	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus!=STATE_HOLDING)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	//add,xzg,2010/02/10,E----------
	CmdEndHold();
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_SendData(objArgParams)
{
try
{
	// objArgParams -> データ
	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus==STATE_LOGOFF)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	//add,xzg,2010/02/10,E----------
	strMsg=objArgParams.GetString("sMSG");
	if (recMsg.innerText.length>0)
	{
		recMsg.innerText=recMsg.innerText + "\r\n" + "<" + strMsg;
	}
	else
	{
		recMsg.innerText= "<" + strMsg;
	}
	recMsg.scrollTop=recMsg.scrollHeight;
	objUmParams= CreateParams();
	objUmParams.SetString("vMessage", strMsg);
	SendEvent("UM_MESSAGE", objUmParams);
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}
		
}

function Acx_GetAcdGroupList(objArgParams)
{
try
{
	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus==STATE_LOGOFF)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	//add,xzg,2010/02/10,E----------

	g_ResultCode=1;
	//add,xzg,2010/02/02,S-----
	objRetParams = CreateParams();
	objRetParams.SetParams(g_objGroupList.GetParams());
	//objRetParams.SetParams(objAcxGroupParams.GetParams());
	nCount=objAcxGroupParams.GetIntDefault("gCount",0);
	objRetParams.AddString("gCount",nCount);
	for(i = 1; i <= nCount; i++)
	{	
		gID=objAcxGroupParams.GetStringDefault("gID" +String(i),"");
		gDisp=objAcxGroupParams.GetStringDefault("gDisp" +String(i),"");
		objRetParams.AddString("gID" +String(i),gID);
		objRetParams.AddString("gDisp" +String(i),gDisp);
	}
	//add,xzg,2010/02/02,E-----

	//add,xzg,2010/01/14,S-----	
	if (g_objGroupList.GetIntDefault("Count",0)==0) 
	{
		gCount=g_objGroupList.Count();
		if (gCount>1)
		{
			gCount=gCount/2;
			//update,xzg,2010/02/02,S---------
			//g_objGroupList.SetInt("Count",gCount);
			objRetParams.SetInt("Count",gCount);
			//update,xzg,2010/02/02,E---------
		}
	}
	//add,xzg,2010/01/14,E-----
	//update,xzg,2010/02/02,S---------
	//return g_objGroupList.GetParams();
	return objRetParams.GetParams();
	//update,xzg,2010/02/02,E---------
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function CallBack(objWin)
{
	g_objWin=objWin;
	AgentListTimer=window.setInterval("checkAgentList()",100);

}   
function checkAgentList()
{
	try
	{
	if (g_getAgentList==1)
	{
		g_getAgentList=0;
		window.clearInterval(AgentListTimer);
		g_objWin.close();
	}
	}
	catch(e)
	{

	}
}
function Acx_GetAgentList(objArgParams)
{
try
{
	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus==STATE_LOGOFF)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	//add,xzg,2010/02/10,E----------

	g_ResultCode=1;
	g_cmdGetList=0;
	if (g_getAgentList==0)
	{
	 	CmdGetList();
		//for(i = 1; i<=1000; i++)
		//{
			;
		//}

		z=window.external.ShowModalDialog(
				"aa.asp", window,
				"dialogWidth:0px;dialogHeight:0px;center:yes;help:no;unadorne:yes;status:no");

		g_getAgentList=0;
		return g_objAgentList.GetParams();
	}
	else
	{
		g_getAgentList=0;
		return g_objAgentList.GetParams();
	}
}
catch(e)
	{
		g_ResultCode=0;	
	}

}
// 追加
function Acx_PlayTranRecord(objArgParams)
{
try
{
	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus==STATE_LOGOFF) 
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	//add,xzg,2010/02/10,E----------
	//update,xzg,2010/02/19,S----------
	//nEventId = objArgParams.GetInt("nEventId");
	gPlayEventId = objArgParams.GetInt("nEventId");
	//update,xzg,2010/02/19,S----------
	//agent=objProfile.GetStringDefault("sAgentId", "No");

	//add,xzg,2010/02/19,S----------
	playRecordTime=window.setInterval("playTelRecord()",100);
	//add,xzg,2010/02/19,E----------
/*
	window.open('TelRecord3.asp?eid=' + nEventId + '&agent=' + agent, "playvoice1",
				'height=100px,width=300px,menubar=no,left=200,top=200,toolbar=no,scrollbars=no;');

window.external.ShowModelessDialog(
				'TelRecord3.asp?eid=' + nEventId + '&agent=' + agent,
				window,
				"dialogWidth:300px;dialogHeight:100px;center:yes;status:no");
*/
	g_ResultCode=1;
	// objArgParams -> オプションデータ
}
catch(e)
	{
		g_ResultCode=0;	
	}

}
function playTelRecord()
{
try
	{
		
		window.clearInterval(playRecordTime);
		agent=objProfile.GetStringDefault("sAgentId", "No");
		window.open('TelRecord3.asp?eid=' + gPlayEventId + '&agent=' + agent, "playvoice1",
				'height=100px,width=300px,menubar=no,left=200,top=200,toolbar=no,scrollbars=no;');
	}
catch(e)
	{
		g_ResultCode=0;	
	}
}
function Acx_SetCustInfo(objCpfParams)
{
try
{
	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus==STATE_LOGOFF) 
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	//add,xzg,2010/02/10,E----------

	//add,xzg,2010/02/10,S----------
	if (g_nAgentStatus!=STATE_CONNECT && g_nAgentStatus!=STATE_HOLDING )
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	//add,xzg,2010/02/10,E----------

	//alert(objCpfParams.GetParams());
	objUmParams= CreateParams();
	
	vTemp=objCpfParams.GetStringDefault("nEventId","");
	objUmParams.SetString("iSessionProfileID", vTemp);

	vTemp=objCpfParams.GetStringDefault("nTag1","");
	objUmParams.SetString("iCustTag", vTemp);

	vTemp=objCpfParams.GetStringDefault("sTag3","");
	objUmParams.SetString("vCustTag", vTemp);

	vTemp=objCpfParams.GetStringDefault("vCallerID","");
	if (vTemp.length>0) objUmParams.SetString("vCallerID", "");

	vTemp=objCpfParams.GetStringDefault("vCalleeID","");
	if (vTemp.length>0) objUmParams.SetString("vCalleeID", "");
	vTemp=objCpfParams.GetStringDefault("iCustomerID","");
	if (vTemp.length>0) objUmParams.SetString("iCustomerID", "");
	vTemp=objCpfParams.GetStringDefault("iMatterID","");
	if (vTemp.length>0) objUmParams.SetString("iMatterID", "");
	SendEvent("UM_SET_CUST_INFO", objUmParams);
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}
function Acx_GetCustInfo(nEventId)
{
try
{
	objRetParams = CreateParams();
	g_ResultCode=1;
	return objRetParams.GetParams();

}
catch(e)
	{
		g_ResultCode=0;	
	}

}

//add,xzg,SFA,S----------------
function Acx_TelRecord(objArgParams)
{
try
{

	if (g_nAgentStatus==STATE_LOGOFF)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	
	if ( g_nAgentStatus!=STATE_WAIT &&  g_nAgentStatus!=STATE_WORKTIME && g_nAgentStatus!=STATE_SEATOFF)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	

	CmdRecordList();
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}
function Acx_CallBack(objArgParams)
{
try
{

	if (g_nAgentStatus==STATE_LOGOFF)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	
	if (g_nAgentStatus!=STATE_WAIT && g_nAgentStatus!=STATE_WORKTIME && g_nAgentStatus!=STATE_SEATOFF)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	
	
	CmdCallBack();
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_MyUser(objArgParams)
{
try
{

	if (g_nAgentStatus==STATE_LOGOFF)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	/*
	if (g_nAgentStatus!=STATE_WAIT && g_nAgentStatus!=STATE_WORKTIME && g_nAgentStatus!=STATE_SEATOFF)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	
	*/
	CmdOption();
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_SkyCall(objArgParams)
{
try
{

	if (g_nAgentStatus==STATE_LOGOFF)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	/*
	if (g_nAgentStatus!=STATE_WAIT && g_nAgentStatus!=STATE_WORKTIME && g_nAgentStatus!=STATE_SEATOFF)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	
	*/
	cmdMakeCall();
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}
function Acx_CTRelease(objArgParams)
{
try
{

	if (g_nAgentStatus==STATE_LOGOFF)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	/*
	if (g_nAgentStatus!=STATE_WAIT && g_nAgentStatus!=STATE_WORKTIME && g_nAgentStatus!=STATE_SEATOFF)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	
	*/
	cmdCTRelease();
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}
function Acx_Chat(objArgParams)
{
try
{

	if (g_nAgentStatus==STATE_LOGOFF)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3001;
		return;
	}
	/*
	if (g_nAgentStatus!=STATE_WAIT && g_nAgentStatus!=STATE_WORKTIME && g_nAgentStatus!=STATE_SEATOFF)
	{
		g_ResultCode=0;
		g_ResultCodeEx=3100;
		return;
	}
	
	*/
	//window.external.Chat();
	
	if (g_PChat==null)
	{
		g_PChat = window.open('agentpanel_Chat.asp', "Chat",
			'height=200px,width=400px,left=10,top=100,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
		g_PChat.focus();

	}
	else
	{
		if (win_closed(g_PChat))
		{
			g_PChat = window.open('agentpanel_Chat.asp', "Chat",
				'height=200px,width=400px,left=10,top=100,menubar=no,toolbar=no,scrollbars=yes,resizable=true;');
		}
		g_PChat.focus();
	}
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}
function Acx_SetPWD(objArgParams)
{
try
{

	//if (g_nAgentStatus==STATE_LOGOFF)
	//{
	//	g_ResultCode=0;
	//	g_ResultCodeEx=3001;
	//	return;
	//}
	//alert(1);
	window.external.ShowPwdSet();
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

//add,xzg,SFA,E----------------
//////////////////////////////////////////////////////////////////////
// プロパティ

function Acx_Get_Server(objArgParams)
{
try
{
	objRetParams = CreateParams();
	objRetParams.SetString("sRetVal", "not support");
	g_ResultCode=1;
	return objRetParams.GetParams();

}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_Get_AgentAddress(objArgParams)
{
try
{
	objProfile = window.external.Profile;
	objProfile.SelectSection("AgentPanel");
	value = objProfile.GetStringDefault("sPhoneNo", "");
	objRetParams = CreateParams();
	objRetParams.SetString("sRetVal", value);
	g_ResultCode=1;
	return objRetParams.GetParams();

}
catch(e)
	{
		g_ResultCode=0;	
	}

}
function Acx_Set_AgentAddress(objArgParams)
{
try
{
	sNewVal = objArgParams.GetString("sNewVal");
	objProfile = window.external.Profile;
	objProfile.SelectSection("AgentPanel");
	objProfile.SetString("sPhoneNo", sNewVal);
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}
function Acx_Get_AgentId(objArgParams)
{
try
{
	objProfile = window.external.Profile;
	objProfile.SelectSection("AgentPanel");
	agentID = objProfile.GetStringDefault("sAgentId", "");
	objRetParams = CreateParams();
	objRetParams.SetString("sRetVal", agentID);
	g_ResultCode=1;
	return objRetParams.GetParams();
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_Set_AgentId(objArgParams)
{
try
{
	sNewVal = objArgParams.GetString("sNewVal");
	objProfile = window.external.Profile;
	objProfile.SelectSection("AgentPanel");
	objProfile.SetString("sAgentId", sNewVal);
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_Get_Password(objArgParams)
{
try
{
	objProfile = window.external.Profile;
	objProfile.SelectSection("AgentPanel");
	value = objProfile.GetStringDefault("sPass", "");
	objRetParams = CreateParams();
	objRetParams.SetString("sRetVal", value);
	g_ResultCode=1;
	return objRetParams.GetParams();
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_Set_Password(objArgParams)
{
try
{
	sNewVal = objArgParams.GetString("sNewVal");
	objProfile = window.external.Profile;
	objProfile.SelectSection("AgentPanel");
	objProfile.SetString("sPass", sNewVal);
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_Get_AfterLoginMode(objArgParams)
{

}

function Acx_Set_AfterLoginMode(objArgParams)
{

}

function Acx_Get_CallTimeOut(objArgParams)
{
try
{
	objProfile = window.external.Profile;
	objProfile.SelectSection("AgentPanel");
	value = objProfile.GetStringDefault("sWaitTime", "");

	objRetParams = CreateParams();
	objRetParams.SetInt("nRetVal", value);
	g_ResultCode=1;
	return objRetParams.GetParams();
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_Set_CallTimeOut(objArgParams)
{
try
{
	nNewVal = objArgParams.GetInt("nNewVal");
	objProfile = window.external.Profile;
	objProfile.SelectSection("AgentPanel");
	objProfile.SetString("sWaitTime", nNewVal);
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_Get_CallState(objArgParams)
{
try
{
	if (g_nAgentStatus==STATE_CALLING || g_nAgentStatus==STATE_NMCALLING
		|| g_nAgentStatus==STATE_TRANCALLING)
	{
		nAgentStatus=1;
	}
	else if (g_nAgentStatus==STATE_OFFERING )
	{
		nAgentStatus=2;
	}
	//g_nAgentStatus==STATE_SWITCHING
	else if (g_nAgentStatus==STATE_CONNECT || g_nAgentStatus==STATE_TRANSFERING 
			|| g_nAgentStatus==STATE_TRANOFFERING 
			)
	{
		nAgentStatus=3;
	}
	else if (g_nAgentStatus==STATE_HOLDING)
	{
		nAgentStatus=4;
	}
	else 
	{
		nAgentStatus=0;
	}

	objRetParams = CreateParams();
	//objRetParams.SetParams(objChangeAgentParams.GetParams());
	objRetParams.SetInt("nRetVal", nAgentStatus);
	g_ResultCode=1;
	return objRetParams.GetParams();
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_Get_AgentState(objArgParams)
{
try
{
	//受付可
	if (g_nAgentStatus==STATE_WAIT)
	{
		nAgentStatus=0;
	}
	//Work
	else if (g_nAgentStatus==STATE_WORKTIME)
	{
		nAgentStatus=1;
	}
	//seatoff
	else if (g_nAgentStatus==STATE_SEATOFF)
	{
		nAgentStatus=2;
	}
	//busy
	else if (g_nAgentStatus==1)
	{
		nAgentStatus=4;
	}
	else 
	{
		nAgentStatus=3;
	}
	objRetParams = CreateParams();
	//objRetParams.SetParams(objChangeAgentParams.GetParams());
	objRetParams.SetInt("nRetVal", nAgentStatus);
	g_ResultCode=1;
	return objRetParams.GetParams();
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_Get_ResultCode(objArgParams)
{
try
{
	objRetParams = CreateParams();
	objRetParams.SetInt("nRetVal", g_ResultCode);
	g_ResultCode=1;
	return objRetParams.GetParams();
}
catch(e)
	{
		//g_ResultCode=0;	
	}

}

function Acx_Get_ResultCodeExtended(objArgParams)
{
try
{
	objRetParams = CreateParams();
	//update,xzg,2010/02/05,S----
	//objRetParams.SetInt("nRetVal", 1);
	objRetParams.SetInt("nRetVal", g_ResultCodeEx);
	//update,xzg,2010/02/05,E----
	return objRetParams.GetParams();
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

function Acx_Get_AgentPanelVersion(objArgParams)
{
try
{
	objRetParams = CreateParams();
	objRetParams.SetString("sRetVal", "1.0.0.0");
	g_ResultCode=1;
	return objRetParams.GetParams();
}
catch(e)
	{
		g_ResultCode=0;	
	}

}
// 追加
function Acx_Get_AfterBusyMode(objArgParams)
{
try
{
	objRetParams = CreateParams();
	objRetParams.SetInt("nRetVal", 10000);
	g_ResultCode=1;
	return objRetParams.GetParams();
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

// 追加
function Acx_Set_AfterBusyMode(objArgParams)
{
try
{
	nNewVal = objArgParams.GetInt("nNewVal");
	g_ResultCode=1;
}
catch(e)
	{
		g_ResultCode=0;	
	}

}

//////////////////////////////////////////////////////////////////////
// イベント発行関数

function Acx_OnOffering(objArgParams)
{
	//add,xzg,2010/02/09,S------
	sCallType=objArgParams.GetStringDefault("iMatterID","");
	if (sCallType=="1" || sCallType=="2") 	g_CallType=sCallType;
	else  g_CallType="2";
	//add,xzg,2010/02/09,E------

	//add,xzg,acx,2010/02/17,S---------
	agentTrans=objArgParams.GetStringDefault("vFuncType", "0");
	if (agentTrans=="2") g_AcxAgentTrans=1;
	else g_AcxAgentTrans=0;
	//add,xzg,acx,2010/02/17,E---------

	sCallerId = objArgParams.GetStringDefault("vCallerID", "");
	sCalledId=objArgParams.GetStringDefault("vCalleeID", "");
	//nSkill = objArgParams.GetStringDefault("iSkillID", "");
	nSkill = objArgParams.GetStringDefault("vDistGroup", "");
	nEventId=objArgParams.GetIntDefault("iSessionProfileID", 0);
	objArgParams.SetInt("nEventId", nEventId);
	//objArgParams.SetInt("nEventId", objArgParams.GetStringDefault("iSessionProfileID","0"));
	objArgParams.SetString("sCallerId", sCallerId);
	objArgParams.SetString("sCalledId", sCalledId);
	objArgParams.SetString("sAcdGroupId", nSkill);
	//add,SFA,S
	objArgParams.SetString("sGroupId", objSmParams.GetStringDefault("vIncmGroup", ""));
	if (nSkill=="コムデザイン")
		objArgParams.SetString("sPopURL", "https://na6.salesforce.com/003/o");
	else if (nSkill=="BRICCS提供")
		objArgParams.SetString("sPopURL", "https://na6.salesforce.com/006/o");
	else
		objArgParams.SetString("sPopURL", "https://na6.salesforce.com/003/o");
	//add,SFA,E

	// objArgParams <- 追加のデータ
	window.external.AcxSendEvent("OnOffering", objArgParams.GetParams());

}

function Acx_OnConnected(objArgParams)
{
	//add,xzg,acx,2010/02/09,S---------
	g_HasConneted=1;
//add,xzg,acx,2010/02/17,S---------
	if (g_AcxAgentTrans==1)
	{
//add,xzg,acx,2010/02/17,E---------
		if (g_TransConnected=="0") g_TransConnected="1";
	}
	//add,xzg,acx,2010/02/09,E---------

	objSetParams = CreateParams();
	//objSetParams.SetParams(objArgParams.GetParams());
	objArgParams.SetInt("nEventId", objArgParams.GetStringDefault("iSessionProfileID","0"));
	window.external.AcxSendEvent("OnConnected", objArgParams.GetParams());

}
// 変更
function Acx_OnDisconnected(objArgParams)
{
	objArgParams = CreateParams();
	objArgParams.SetInt("nEventId", objArgParams.GetStringDefault("iSessionProfileID","0"));
	window.external.AcxSendEvent("OnDisconnected", objArgParams.GetParams());
	g_ResultCode=1;
}

//function Acx_OnDisconnectedHeld()
//{
//	window.external.AcxSendEvent("OnDisconnectedHeld", "");
//}


// 変更
function Acx_OnDisconnectedHeld(objArgParams)
{
	objArgParams = CreateParams();
	//objArgParams.SetInt("nEventId", nEventId);
	objArgParams.SetInt("nEventId", objArgParams.GetStringDefault("iSessionProfileID","0"));
	window.external.AcxSendEvent("OnDisconnectedHeld", objArgParams.GetParams());
}

// 変更
function Acx_OnCallFailed(objArgParams,nResult)
{
	//add,xzg,2010/02/05,S---
	g_ResultCodeEx=2000+nResult;
	//add,xzg,2010/02/05,E---

	objArgParams = CreateParams();
	//objArgParams.SetInt("nEventId", objArgParams.GetStringDefault("iSessionProfileID","0"));
	objArgParams.SetInt("nEventId", g_EventID);	
	objArgParams.SetInt("nResult", nResult);
	window.external.AcxSendEvent("OnCallFailed", objArgParams.GetParams());

}

function Acx_OnChangeCallState(objArgParams)
{
	//objArgParams = CreateParams(); //del,xzg,SFA,2010/08/02
	window.external.AcxSendEvent("OnChangeCallState", objArgParams.GetParams());
}

//function Acx_OnDataReceived(sAgentId)
function Acx_OnDataReceived(sMSG)
{
	objArgParams = CreateParams();
	//objArgParams.SetString("sAgentId", sCallerId);
	// objArgParams <- 追加のデータ
	objArgParams.SetString("sAgentId", "1001");
	objArgParams.SetString("sMSG", sMSG);
	window.external.AcxSendEvent("OnDataReceived", objArgParams.GetParams());
}
function Acx_OnMakeCallRequest()
{
	objArgParams = CreateParams();
	window.external.AcxSendEvent("OnMakeCallRequest", objArgParams.GetParams());
}
function Acx_OnServiceStopped(nResult)
{
	objArgParams = CreateParams();
	objArgParams.SetInt("nResult", nResult);
	window.external.AcxSendEvent("OnServiceStopped", objArgParams.GetParams());
}

function Acx_OnChangeAgentState(objArgParams)
{
	//add,xzg,2010/02/02,S------
	//objChangeAgentParams= CreateParams();
	//objChangeAgentParams.SetParams(objArgParams.GetParams());
	//add,xzg,2010/02/02,E------
	//update,xzg,acx,S---------
	//window.external.AcxSendEvent("OnChangeAgentState", "");
	//Acx_OnChangeCallState();
	curCallStatus=-1;
	curAgentStatus=-1;
	sessionID=objArgParams.GetStringDefault("iSessionProfileID","NONE");
	if (sessionID.length>0 && sessionID!="NONE")
	{
		g_EventID=sessionID;
	}
	//wait
	if (g_nAgentStatus==STATE_WAIT)
	{
		curAgentStatus=0;
	}
	//Work
	else if (g_nAgentStatus==STATE_WORKTIME)
	{
		curAgentStatus=1;
	}
	//seatoff
	else if (g_nAgentStatus==STATE_SEATOFF)
	{
		curAgentStatus=2;
	}
	//busy
	else if (g_nAgentStatus==1)
	{
		curAgentStatus=4;
	}
	else 
	{
		curAgentStatus=3;
	}

	//add,xzg,2010/02/17,S---
	if (g_nAgentStatus==STATE_LOGOFF)
		{
			window.external.AcxSendEvent("OnChangeAgentState", objRetParams.GetParams());
			return;
		}
	//add,xzg,2010/02/17,E---
	//add,xzg,acx,2010/02/09,S---------
	//add,xzg,acx,2010/02/17,STATE_TRANCALLING---------
	if (STATE_TRANSFERING==g_nAgentStatus|| STATE_TRANOFFERING==g_nAgentStatus
		|| STATE_TRANCALLING==g_nAgentStatus)
		 g_TransConnected="0";
	//if (STATE_TRANSFERING==g_nAgentStatus|| STATE_TRANOFFERING==g_nAgentStatus) g_HasConneted="1";
	//add,xzg,acx,2010/02/09,E---------
	if (curAgentStatus!=g_PreAgentStatus) 
	{
		objRetParams = CreateParams();		
		if (g_PreAgentStatus==3)
		{
			g_TelNo=objArgParams.GetStringDefault("vCaller","");
			if (g_TelNo!="")
				g_TelNo=g_TelNo.replace(new RegExp("[^0-9]","gm"),"");
			g_CallDateE=getCurrentTime();
			objRetParams.SetString("nEventId",g_EventID);
			objRetParams.SetString("CallStartTime",g_CallDateS);
			objRetParams.SetString("CallEndTime",g_CallDateE);	
			objRetParams.SetString("CallType",g_CallType);
			objRetParams.SetString("TelNo",g_TelNo);
			vReason=objSmParams.GetStringDefault("vReason","");
			if (vReason!="0")  vReason="1";
			//add,xzg,acx,2010/02/09,S---------
			if (g_HasConneted==0) vReason="1";
			g_HasConneted=0;
			//add,xzg,acx,2010/02/09,E---------
			objRetParams.SetString("vReason",vReason);
			//add,xzg,acx,2010/02/09,S---------
			//add,xzg,acx,2010/02/17,S---------
			if (g_AcxAgentTrans==1)
			{
				if (vReason=="1")
					objRetParams.SetString("vCancel","0");
				else
					objRetParams.SetString("vCancel","1");
			}
			else
			{
				objRetParams.SetString("vCancel",g_TransConnected);				
			}
				g_TransConnected="-1";
				g_AcxAgentTrans=0;
			//add,xzg,acx,2010/02/17,E---------
			//add,xzg,acx,2010/02/09,E---------
			g_CallType="-1";
			
		}
		else if (curAgentStatus==3)
		{
			g_CallDateS=getCurrentTime();
		}
		window.external.AcxSendEvent("OnChangeAgentState", objRetParams.GetParams());
		
	}

	g_PreAgentStatus=curAgentStatus;

	if (g_nAgentStatus==STATE_CALLING || g_nAgentStatus==STATE_NMCALLING
			|| g_nAgentStatus==STATE_TRANCALLING)
	{
		curCallStatus=1;
	}
	//add,xzg,2010/09/15,S
	//else if (g_nAgentStatus==STATE_NMCALLING)
	//{
	//	;
	//}
	//add,xzg,2010/09/15,E
	else if (g_nAgentStatus==STATE_OFFERING)
	{
		curCallStatus=2;
	}
	//g_nAgentStatus==STATE_SWITCHING
	else if (g_nAgentStatus==STATE_CONNECT || g_nAgentStatus==STATE_TRANSFERING 
		|| g_nAgentStatus==STATE_TRANOFFERING
		)
	{
		curCallStatus=3;
	}
	else if (g_nAgentStatus==STATE_HOLDING)
	{
		curCallStatus=4;
	}
	else 
	{
		curCallStatus=0;
	}
	//add,xzg,2010/02/10,S----------
	if (g_PreCallStatus==1 && curCallStatus==0) g_ResultCodeEx=2701;
	if (g_PreCallStatus==2 && curCallStatus==0) g_ResultCodeEx=2702;
	//add,xzg,2010/02/10,E----------
	if (g_PreCallStatus!=curCallStatus) Acx_OnChangeCallState(objArgParams);
	g_PreCallStatus=curCallStatus;
	//update,xzg,acx,E---------
}
//add,xzg,2009/12/21,E----
//add,xzg,SFA,S
function Acx_OnChangeQueVoice(iNumberOfVmail,iNumberOfQueCall)
{
//if (iNumberOfVmail==0) iNumberOfVmail=1;
//if (iNumberOfQueCall==0) iNumberOfQueCall=1;
	objArgParams = CreateParams();
	objArgParams.SetInt("Voicemail", iNumberOfVmail);
	objArgParams.SetInt("QueCall", iNumberOfQueCall);
	window.external.AcxSendEvent("OnChangeQueVoice", objArgParams.GetParams());
}
function Acx_OnOptionInfo()
{
	objOptionInfoParams= CreateParams();
	//telrecord,callback,myuser,skycall,ctrealse,chat
	objOptionInfoParams.SetString("Option", "111111");
	objOptionInfoParams.SetString("IsSFASet", "1");
	objOptionInfoParams.SetString("SFAObject", "New_Lead__C");
	objOptionInfoParams.SetString("SFAObjectField", "PopURL__C");

	objOptionInfoParams.SetString("IsSFATaskSet", "0");
	objOptionInfoParams.SetString("SFATaskField", "ngcp__CTe1Record__c");
	if (hTenantID.value=='05058085468')
	{
		objOptionInfoParams.SetString("IsInfo", "1");
		objOptionInfoParams.SetString("InfoTable", "ngcp__Pop__c");
		objOptionInfoParams.SetString("Info", "ngcp__tel__c");
	}
	else
	{
		objOptionInfoParams.SetString("IsInfo", "0");
		objOptionInfoParams.SetString("InfoTable", "");
		objOptionInfoParams.SetString("Info", "");
	}
	objOptionInfoParams.SetString("IsInfoEx", "0");
	objOptionInfoParams.SetString("InfoTableEx", "");
	objOptionInfoParams.SetString("InfoEx", "");
	window.external.AcxSendEvent("OnOptionInfo", objOptionInfoParams.GetParams());
}
//add,xzg,SFA,E
//add,xzg,2010/02/02,S------
function getCurrentTime()
{
	var now= new Date();
	var year=now.getYear();
	var month=now.getMonth()+1;
	var day=now.getDate();
	var hour=now.getHours();
	var minute=now.getMinutes();
	var second=now.getSeconds();
	return year+"/"+month + "/"+ day + " "+ hour +  ":" + minute + ":" + second;
}
//add,xzg,2010/02/02,E------